Docker install a full set of documentation related to the environment and small skills
The following environments are all ubuntu16.04, the main installation docker, docker-compose, docker warehouses.
Docker installation
Reference official
A: active Installation
Docker installation of Ubuntu:
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
CentOS installation of Docker:
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce
systemctl start docker
systemctl enable docker
docker version
B: Passive installation
Ubuntu:
First download has been compiled package .
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_18.06.1~ce~3-0~ubuntu_amd64.deb
sudo dpkg -i docker-ce_18.06.1~ce~3-0~ubuntu_amd64.deb
sudo docker run helloworld
--
After No. 1 March 2017, the version Docker's name began to change, while the CE version and EE versions separately, represent 18.03 on March 18 release.
Naming offline installation before docker (docker-engine depends on (> = 2.4.6) libltdl7;):
wget https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_1.12.1-0~xenial_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/libt/libtool/libltdl7_2.4.6-4_amd64.deb
dpkg -i *.deb
Docker-compose Installation
We can manage multiple containers docker-compose.
Offline installation:
wget https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m`
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Docker Hub Installation
VMware's open source Docker Registry management of enterprise-wide project: Harbor .
With the warehouse, we can directly push up the mirror, and then pull from elsewhere, without the help of U disk.
Installation Reference:
Environmental rely newer docker1.10+
and docker-compose1.60+
and python2.7
we chose the offline installation:
wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.0-rc3.tgz
tar xvf harbor-offline-installer-v1.6.0-rc3.tgz
cd harbor
Edit docker-compose.yml
:
proxy:
image: goharbor/nginx-photon:v1.6.0
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
ports:
- 8888:80
- 1443:443
- 4443:4443
Modify the common/templates/registry/config.yml
file to the 8888
port:
vim common/templates/registry/config.yml
auth:
token:
issuer: harbor-token-issuer
realm: $public_url:8888/service/token
rootcertbundle: /etc/registry/root.crt
service: harbor-registry
Edit harbor.cfg
:
hostname = 192.168.152.12
harbor_admin_password = admin
Launch and landing:
sudo su
ufw allow 8888
./prepare
docker-compose up -d
Open: http://192.168.152.12:8888, account | password: admin
Docker Configuration
You can configure some warehouse address (the first one is Ali cloud acceleration warehouse address, and the second ignored https security)
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://ztndgg1k.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.0.88:8888"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Push and then log:
sudo docker login http://192.168.0.88:8888
sudo docker tag mysql:5.7 192.168.0.88:8888/public/mysql:5.7
docker push 192.168.0.88:8888/public/mysql:5.7
Docker use a particular scene
Offline Mirror
If you can not access the Internet, you can save and load to save and load the image
docker save xxx:1.0 > /root/api1.0.tar
docker load < /root/api1.0.tar
docker images
Precautions
Development and use docker
after a long time, some experience:
- EntryPoint, represents a mirror initialization command to be executed, can not be rewritten covered, the CMD parameter can be connected at its rear, so that those parameters can be changed are written in the CMD.
- The CMD, default parameter indicates the Mirror operation, can be rewritten covered, docker run parameters if followed, Oh.
- ENTRYPOINT / CMD can only exist in the file once, and the last one will, there is more, only the last one will work, others are not! CMD can add, see 1
- Need to initialize run multiple commands, you can use && separated from one another, but in the end a need for the command to run indefinitely, or else after running out of the container