ubuntu 安装 docker以及docker-compose
Docker is supported on these Ubuntu operating systems:Ubuntu Xenial 16.04 (LTS)Ubuntu Wily 15.10Ubuntu Trusty 14.04 (LTS)Ubuntu Precise 12.04 (LTS)准备:Update your apt sourcesDocker’s
Docker is supported on these Ubuntu operating systems:
- Ubuntu Xenial 16.04 (LTS)
- Ubuntu Wily 15.10
- Ubuntu Trusty 14.04 (LTS)
- Ubuntu Precise 12.04 (LTS)
update your apt sources:
Docker’s APT
repository contains Docker 1.7.1 and higher. To set APT
to use packages from the Docker repository:
-
Log into your machine as a user with
sudo
orroot
privileges. -
Open a terminal window.
-
Update package information, ensure that APT works with the
https
method, and that CA certificates are installed.$ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates
-
Add the new
GPG
key.$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
-
Find the entry for your Ubuntu operating system.
The entry determines where APT will search for packages. The possible entries are:
Ubuntu version Repository Precise 12.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-precise main
Trusty 14.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-trusty main
Wily 15.10 deb https://apt.dockerproject.org/repo ubuntu-wily main
Xenial 16.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-xenial main
Note: Docker does not provide packages for all architectures. Binary artifacts are built nightly, and you can download them from https://master.dockerproject.org. To install docker on a multi-architecture system, add an
[arch=...]
clause to the entry. Refer to Debian Multiarch wiki for details. -
Run the following command, substituting the entry for your operating system for the placeholder
<REPO>
.$ echo "<REPO>" | sudo tee /etc/apt/sources.list.d/docker.list
-
Update the
APT
package index.$ sudo apt-get update
-
Verify that
APT
is pulling from the right repository.When you run the following command, an entry is returned for each version of Docker that is available for you to install. Each entry should have the URL
https://apt.dockerproject.org/repo/
. The version currently installed is marked with***
.The output below is truncated.$ apt-cache policy docker-engine docker-engine: Installed: 1.12.2-0~trusty Candidate: 1.12.2-0~trusty Version table: *** 1.12.2-0~trusty 0 500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages 100 /var/lib/dpkg/status 1.12.1-0~trusty 0 500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages 1.12.0-0~trusty 0 500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages 1.11.2-0~trusty 0 500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages 1.11.1-0~trusty 0 500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
From now on when you run
apt-get upgrade
,APT
pulls from the new repository.
Then, install Docker using the following:
-
Log into your Ubuntu installation as a user with
sudo
privileges. -
Update your
APT
package index.$ sudo apt-get update
-
Install Docker.
$ sudo apt-get install docker-engine
-
Start the
docker
daemon.$ sudo service docker start
-
Verify
docker
is installed correctly.$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message. Then, it exits.
o create the docker
group and add your user:
-
Log into Ubuntu as a user with
sudo
privileges. -
Create the
docker
group.$ sudo groupadd docker
-
Add your user to
docker
group.$ sudo usermod -aG docker $USER
-
Log out and log back in.
This ensures your user is running with the correct permissions.
-
Verify your work by running
docker
withoutsudo
.$ docker run hello-world
$ sudo apt-get -yqq update #更新apt-get源 $ sudo apt-get -yqq install apt-transport-https ca-certificates $ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D $ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list $ sudo apt-get -yqq update $ apt-cache policy docker-engine#可选 $ sudo apt-get -yqq install linux-image-extra-$(uname -r) linux-image-extra-virtual#可选 $ sudo apt-get -yqq update $ sudo apt-get -yqq install docker-engine $ sudo service docker start #or sudo docker daemon & or docker daemon & or systemctl start docker 都要以root用户执行才可以。 $ sudo docker run hello-world #运行hello-world镜像 $ sudo systemctl enable docker#配置开机启动 #### $ sudo groupadd docker #这一步可以不用,默认会创建docker用户组 $ sudo usermod -aG docker $USER #加入docker用户组,该组的用户才可以 sudo docker 执行docker命令
$sudo curl -fsSL https://get.docker.com/ | sh
安装docker-compose:
$sudo apt-get -yqq install aptitude
$sudo aptitude -y install python-pip
$sudo pip install docker-compose
$sudo docker-compose version
更多推荐
所有评论(0)