Ubuntu docker-compose and install Docker

Description:

This article is Vagrant installation and use of the article, installation and docker-compose the Docker Ubuntu

log in:vagrant ssh

 

 

 

Uninstall the old version of the
old version of Docker called docker or docker-engine, use the following command to uninstall the old version:

$ sudo apt-get remove docker \
docker-engine \
docker.io


Use APT to install
due to the apt source uses HTTPS to ensure that the process of downloading the software is not tampered with. Therefore, we first need to add the use of HTTPS transport packages and CA certificate.

$ sudo apt-get update

$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

In view of the domestic network problems, it is strongly recommended to use domestic sources, please see the official source in comments.

In order to confirm the legitimacy of the downloaded package, you need to add GPG key source software.

$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -


Official sources #
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt -key add -


Then, we need to add to the Docker source software in source.list

$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"

# 官方源
# $ sudo add-apt-repository \
# "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) \
# stable"

The above command will add a stable version of Docker CE APT mirror source, or if you need to test the build daily Docker CE Please change stable to test or nightly.

 

Installation Docker CE
update the apt package cache,

$ sudo apt-get update

Installation docker-ce:

$ sudo apt-get install docker-ce

If you want to specify docker version, you can use the following list your warehouse available version:

apt-cache madison docker-ce

 

 

 

Specifies the version installed

sudo apt-get install docker-ce=18.06.2~ce~3-0~ubuntu

Start Docker CE

$ sudo systemctl enable docker
$ sudo systemctl start docker

Domestic Mirror accelerated.
For systemd system, write /etc/docker/daemon.json in the following (if the file does not exist Please new file)

{

"registry-mirrors": [

"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"

]

}
Note that we must ensure compliance with the json file specification, or Docker will not start.

After restarting the service.

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

Docker establish user groups
in the case, docker command uses the Unix socket communication with Docker engine default. And only the root user and user groups can access the docker Docker engine Unix socket. For security reasons, do not directly use the root user on Linux systems in general. Therefore, a better approach is to require the use of user docker docker to join the user group.

Establish docker Group:

$ sudo groupadd docker

The current user to join docker Group:

$ sudo usermod -aG docker $USER

Check whether the installation was successful

$ docker -v

 

 

 

Installation docker-compose:

You can modify the URL version, custom version you need.

Github源
sudo curl -L https://github.com/docker/compose/releases/download/1.23.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

sudo curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose
Daocloud镜像
curl -L https://get.daocloud.io/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

 

注意:

1.docker-compose和docker的版本对应,官方说明https://docs.docker.com/compose/compose-file/

Guess you like

Origin www.cnblogs.com/jxxiaocao/p/12069139.html