Container operations

1. The pre-configuration

aliyun Mirror address https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

Acceleration address : https: //lvb4p7mn.mirror.aliyuncs.com

For users Docker client version 1.10.0 of greater than

You can modify /etc/docker/daemon.json to use the accelerator daemon configuration file

we /etc/docker/daemon.json

{

  "registry-mirrors": ["https://lvb4p7mn.mirror.aliyuncs.com"]

}

systemctl daemon-reload

systemctl restart docker

 

2.docker operation supplement

Installation image

docker pull alpine

Search Mirror

docker search nginx

Download the official image

docker pull nginx

View Mirror

docker images

 

Export Mirror

docker save nginx > /tmp/nginx.tar.gz

 

tar xf nginx.tar.gz

cat manifest.json   find config field to find a mirrored configuration information

 

Import image

docker load < /tmp/doc/nginx.tar.gz

docker images

 

docker directory

/var/lib/docker/

Mirrored storage

/var/lib/docker/image/overlay2/imagedb/content/sha256

Replace the storage directory

we /usr/lib/systemd/system/docker.service

--graph=/opt/docker

 

Modify dns

cat /etc/resolv.conf

Modify command mirror configuration

docker daemon --help

Boot image

run = create + start

docker run -it docker.io/nginx sh  

-i input

- t Terminal

 sh Run

 

docker ps   to see running container

ctrl + p + q exit interactive terminal does not close the container running at

 

yum reinstall httpd  -y  重装

 

docker ps -a  to view all containers

 

Delete container

docker rm -f dc 7f 11b

 

parameter

docker run -it --rm --name mynginx  docker.io/nginx 

--rm container automatically deleted after stop

 

docker run -it -d --name nginx_web docker.io/nginx sh

-d container running in the background (daemon daemon)

 

docker run -it -d --name nginx_web docker.io/nginx

nginx container default execution

nginx -g 'daemon ...  open web services

 

docker logs -f nginx_web1     view a container log (-f and tail -f the same effect)

 

View Container Details

docker inspect mynginx   

Into the container

docker attach mynginx

 

docker exec -it a4 bash   recommend this

exec execution parameters

bash bash open command process

This mode exit window of the container will not quit

Guess you like

Origin www.cnblogs.com/leiwenbin627/p/11210840.html