table of Contents:
- System Environment
- To deploy the installation
- MySQL installation and use of container
1. System Environment
System: Centos7.x
Docker version: CE Free
2. To deploy the installation
1, the installation dependencies
[root@docker001 ~]# yum install -y -yum-utils \
> device-mapper-persistent-data \
> lvm2
2, the installation management pack
[root@docker001 ~]# yum-config-manager \
> --add-repo \
> https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
3, installation
1) Install the latest version
[root@docker001 ~]# yum install docker-ce docker-ce-cli containerd.io
2) specify the version installed
[root@docker001 ~]# yum list docker-ce --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 @docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
Available Packages
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
VERSION_STRING = docker-ce.x86_64_3:18.09.4-3.el7
3) RPM package installation
RPM package Download: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
[root@docker001 ~]# yum install /path/to/package.rpm
4. Verify that the startup
[root@docker001 ~]# systemctl start docker
[root@docker001 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2019-03-30 17:01:10 CST; 20s ago
Docs: https://docs.docker.com
Main PID: 9810 (dockerd)
Memory: 29.4M
CGroup: /system.slice/docker.service
└─9810 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.515160601+08:00" level=info msg="pickfirstBalancer: HandleSubConnStateChan...dule=grpc
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.540195341+08:00" level=info msg="Graph migration to content-addressability... seconds"
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.540735439+08:00" level=info msg="Loading containers: start."
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.654089229+08:00" level=info msg="Default bridge (docker0) is assigned with... address"
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.698740234+08:00" level=info msg="Loading containers: done."
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.717392389+08:00" level=warning msg="Not using native diff for overlay2, th...=overlay2
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.717607234+08:00" level=info msg="Docker daemon" commit=d14af54 graphdriver...n=18.09.4
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.717695940+08:00" level=info msg="Daemon has completed initialization"
Mar 30 17:01:10 docker001 dockerd[9810]: time="2019-03-30T17:01:10.737278066+08:00" level=info msg="API listen on /var/run/docker.sock"
Mar 30 17:01:10 docker001 systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
5, the official test cases
[root@docker001 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
MySQL install and simple to use
1, copy and pull mysql's image to the local
[root@docker001 ~]# docker pull mysql
2, view downloaded to the local image
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 98455b9624a9 3 days ago 372MB
hello-world latest fce289e99eb9 2 months ago 1.84kB
3, log on MySQL
[root@docker001 ~]# docker run --name mysql1 -p3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
[root@docker001 ~]# docker exec -it mysql mysql -uroot -p
4, view the running process
[root@docker001 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f9191d5321e mysql:5.7 "docker-entrypoint.s…" 23 seconds ago Up 23 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp mysql1
26d6aea338f0 hello-world "/hello" 13 minutes ago Exited (0) 13 minutes ago flamboyant_stallman
5, into the container
[root@docker001 ~]# docker exec -it mysql bash
root@baa487819412:/#