linux install docker startup and shutdown

Why does docker appear?

One product: development-online two environments! The application environment also needs application configuration, so in order to maintain the uniformity and uniqueness of the environment, docker appears, and the environment deployment is very troublesome. If your company has several or dozens of servers, don't you want to configure each server? Effortless.

docker official documentation

Official website: https://www.docker.com/
Docker Chinese official document: http://www.dockerinfo.net/document
Document: https://docs.docker.com/Warehouse
address: https://hub.docker .com/ Publish your mirror on this, others can get it, you can also go to http://hub.daocloud.io/ mirror market

Three cores of docker

Image (image) : docker image is like a template, which can be used to create container services, such as: tomcat image ==> run (run) ==> tomcat01 container (providing server), through this image, you can create multiple Containers (where the final service run or project run is in the container).
Docker image loading principle: It is actually composed of a layer-by-layer file system. This layer of file system UniosFS (Union File System)
container (contalner) : Docker uses container technology to independently run one or a group of applications, through mirroring to create.
Start, stop, delete, basic commands.
At present, this container can be understood as a simple linux system
repository (repository) : the repository is the place where images are stored; it is divided into private warehouses and public warehouses.

install docker

Check the environment
1. Centos7 or above
2. The system kernel is above 3.10 Command: uname -r
insert image description here
3. System version command: cat /etc/os-release
insert image description here
Install docker
1. You can first check whether your linux has docker installed and
enter the command: docker This will appear if the version
insert image description here
has not been installed.
If you have installed it, you can uninstall the old docker
command as follows:
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine
insert image description here
Because I have not installed docker, so No Match for appears

2. Required installation package
Command: yum install -y yum-utils

3. Set the mirror warehouse
yum-config-manager
–add-repo
https://download.docker.com/linux/centos/docker-ce.repo #The default download is from abroad, the download is very slow, don’t use it, use the following this

yum-config-manager
–add-repo
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #Recommended to use domestic Alibaba Cloud image

4. Update the index of the yum package
yum makecache fast
After we update the yum source or configure the yum source, we usually use yum makecache to generate a cache.
This command is to cache the package information locally in advance to improve the search and installation software. speed

5. Install docker related content docker-ce is the community version ee is the enterprise version
yum install docker-ce docker-ce-cli containerd.io
Select all y during the installation process

The sixth step starts docker
systemctl start docker

Step 7: Use the docker version command to check whether the installation is successful. If you can see the information, it means that the docker is successful, as follows:
insert image description here
Step 8: Start the hello-world image
docker run hello-world
After running the command, it appears: Unable to find image ' After hello-world:latest' locally, don't worry, wait a minute,
it will automatically download the image first and print out latest: Pulling from library/hello-world
and then print out Hello from Docker, it means the startup is successful

Step 9: Check out the downloaded hello-world image
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 10 months ago 13.3kB

The images downloaded by docker pull are stored in the /var/lib/docker/ folder by default.
Check out the /var/lib/docker/image/overlay2/repositories.json file.

Shut down the docker service and uninstall

shut down the docker service

After stopping docker
centos7, use systemctl to stop docker
. Before centos7, use service docker stop.
If you enter this command, it appears:
Warning: Stopping docker.service, but it can still be activated by: docker.socket
Then you need to stop docker.socket first
systemctl stop docker.socket
Example:
insert image description here
You find that when you enter the docker service stop command, it can also use the docker command, so if this prompt appears, you need to use the following command to stop the docker service:
insert image description here
Then enter the systemctl status docker command to view the docker startup status. As follows: It is
insert image description here
found that the docker service is stopped, and after entering the docker command, you are prompted that the docker service has not started.
If you want to start directly systemctl start docker just fine.
After restarting the command
centos7, use systemctl restart docker
before centos7 use service docker restart

uninstall docker

1. Uninstall dependencies
yum remove docker-ce docker-ce-cli containerd.io
2. Delete the running environment
rm -rf /var/lib/docker #The default working path of docker

Guess you like

Origin blog.csdn.net/weixin_42273775/article/details/119517061