Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos 7.5 install docker, common commands

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Set up the repository [root@localhost ~] # sudo yum install-y yum-utils device-mapper-persistent-data lvm2 use the following command to set up a stable repository. [root@localhost ~] # sudo yum-config-manager\ >-- add-repo\ > https://download.docker.com/linux/centos/docker-ce.repo installs the latest version of Docker Engine-Community and containerd [root @ localhost ~] # sudo yum install docker-ce docker-ce-cli containerd.io

If you want to install a specific version of Docker Engine-Community, you can use the yum list docker-ce-- showduplicates | sort-r command to find the available version and then install it.

Start Docker [root @ localhost ~] # sudo systemctl start docker to view docker version docker-- version download nginx image and launch [root@localhost ~] # docker pull nginx [root@localhost ~] # docker run-d-p 80:80 nginx #-d background run-p mapping inside and outside port IP/index.html to see if nginx can be accessed

You can also open multiple containers at the same time [root@localhost ~] # docker run-d-p 81:80 nginx enters port 81 nginx to change the configuration file [root@localhost ~] # docker exec-it 9a bashroot@9a9be50b305c:/# cd / usr/share/nginx/html/root@9a9be50b305c:/usr/share/nginx/html# echo hello docker > index.htmlroot@9a9be50b305c:/usr/share/nginx/html# cat index.html hello docker access IP:81

When we put a modified container, save it as a mirror, and keep it changing while running.

Dockerfile: build an image through dockerfile, and launch the container through the image first create a dockerfile file [root@localhost ~] # vi dockerfile

And create an index.html file [root@localhost ~] # vi index.html in this directory

Use the docker built-t command to specify the dockerfile file in the current directory, image name m2, build container [root@localhost ~] # docker build-t m2 .Sending build context to Docker daemon 13.31kBStep 1 ADD 2: FROM nginx-- > f949e7d76d63Step 2 7e2e7d47ad47Successfully built 7e2e7d47ad47Successfully tagged m2:latest run the container [root@localhost ~] # docker run-d-p 83:80 m2859506c5b89d80b0520310cef2e97156e95c2d55292b3644c41906518661fb20 searches ip:83 in the browser to see if nginx is running

The docker save/load command saves an image to a file through docker save

Delete m2 image. Since one container is based on m2 image, you need to delete the container first.

You can see that the m2 image has been deleted.

Remove the image from the file through the docker load command

× × learning

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report