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

Installation sheet docker simple to use command

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Installation

Yum install-y epel-release # install epel source

Yum install-y docker # install docker Container

Docker version # check the version number of docker, including client, server, dependent Go, etc.

Docker info # View system (docker) level information, including managed images, number of containers, etc.

Docker images centos # View centos image

Docker images-- all # View all images

Docker run-I-t centos # starts the centos image

2 Management of mirror images

Docker search centos # search for centos images search in docker index

Docker pull centos # download image is downloaded in docker index

Docker pull hub.c.163.com/library/tomcat:latest

# download from China

Docker images # View all downloaded images

Docker images-a # View all downloaded images (including history)

Docker rm: # Delete one or more image

Image package export, import

Docker export cs2 > centercs3.tar # package the container cs2 into an image

Cat centercs3.tar | docker import-cs3# import image, name is cs3

Docker run-itd-- name cs5 cs3 / bin/bash # create a container cs5 from the image just now

The use of save load

Docker save-o cs.tar docker.io/blinzlerone/ocsinventory-docker-image

# Save the "docker.io/blinzlerone/ocsinventory-docker-image" in docker to tar format

Docker load-input cs.tar

# Import

3. Container management

Docker run-itd-- name center7 hub.c.163.com/library/centos

# create and launch a container called center7. "hub.c.163.com/library/centos" this is the image used

-I allows interaction,-d background starts-t opens the terminal

Docker ps: lists all currently running container

Docker ps-l: lists the most recently launched container

Docker ps-a: list all container (including history, not running)

Docker ps-Q: lists the last run of container ID

Docker stats # checks the status of the container and refreshes it similar to the function of watch-N1 software. Plus-no-stream only crawls once

Docker exec-it ocsweb / bin/bash # enters the container

Docker attach ocsweb # enter the container

# enter the container docker attach 2775cac1c4af docker exec-it 2775cac1c4af / bin/bash # start a bash program of the above ID to start the container docker start/stop/restart center7 again | 2775cac1c4af # start or stop restarting the container, you can use name ID. Add the port mapping docker run-p 8000 ID 80-it docker.io/centos / bin/bash # this can only be added when creating the container. If the container is already running, you can only package the container into an image and create it.

Delete an image or container

Docker rm sad_joliot # use id name to delete a container. Note that the container must be closed before it can be deleted.

Docker rmi docker.io/nginx # Delete an image. Note that if a container uses a modified image, the image cannot be deleted.

4. Change the bridging mode

Now the physical machine network card is changed to bridge mode.

Vim / etc/sysconfig/network-scripts/ifcfg-ens33 # remove the IPOTPROTO=staticONBOOT=yesTYPE=EthernetuBRIDGE= "br0" DEVICE=ens33 of the original interface

Vim / etc/sysconfig/network-scripts/ifcfg-br0 # adds a br type configuration file with ip

OTPROTO=staticONBOOT=yesTYPE=BridgeDEVICE=br0IPADDR=192.168.0.17NETMASK=255.255.255.0GATEWAY=192.168.0.8DNS1=114.114.114.114

Yum install-y git # install and download tool

Git clone https://github.com/jpetazzo/pipework # download software, green

Cp pipework/pipework / usr/local/bin/ # copies the software to the bin directory so that the environment variables can be identified

Pipework br0 cs5 192.168.0.19 Compact 24mm 192.168.0.8

# configure the cs5 with an ip address of 192.168.0.19. The gateway changes the ip of the network segment, and it will be emptied after restart.

Automatically assign IP

Vim / etc/sysconfig/docker

# change it to OPTIONS='--selinux-enabled-bounded br0' in the OPTIONS='--selinux-enabled' line, that is, use the br0 Nic to bridge when the docker service is started. The default is docker0 bridge in nat mode. Note that the IP address assigned after bridging is not obtained from dhcp, but incrementally assigned from 1-254.

Docker run-itd-net=none-name cs7 docker.io/kinogmt/centos-ssh

# create a container cs7,--net=none without configuring any bridges

Pipework br0 cs7 192.168.0.19 IP address manually assigned by 24quarter 192.168.0.8 #

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