Can't remember the docker command? Don't worry. Docker graphical management tool, Portainer, will help you

What is docker? I don't know, just Google it. Many people have a headache when they contact docker, because there are many commands to remember. But the development of IT technology is so amazing. Here comes the non graphical interface management tool. Today, we will introduce Porter, a relatively mature, stable and easy-to-use docker graphical management tool.

Construction of docker basic environment

Use wget tool to download yum source from docker official website:

wget -P /etc/yum.repos.d/ https://download.docker.com/linux/centos/docker-ce.repo

Update yum source cache

yum makecache fast

Install Docker

yum -y install docker-ce

Start Docker and set startup

systemctl start docker
systemctl enable docker

Modify the docker image source - then docker pull will be fast

Add the following parameters to the / etc/docker/daemon.json file (create a new one without the file)


{
  "registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}

Service restart:


systemctl daemon-reload
systemctl restart docker


docker common commands

Find Centos image file in Docker

docker search centos

Download the Centos image file in Docker (download the latest version by default)

docker pull centos

Viewing mirror files in the system

docker images

View all containers in the system

docker ps -all

Enter the container command line

docker exec -ti container ID /bin/bash

Delete container (only stopped containers can be deleted)

docker rm container ID

Force container deletion

docker rm -f container ID

Delete image file

docker rmi image file ID

Get container information

docker inspect image ID

View container IP address

docker inspect 'container ID' |grep IPAddress

View container mapping ports

docker port container ID

Create container

docker run
#- a stdin: Specifies the standard input / output content type. Three options are available: STDIN/STDOUT/STDERR;
#- d: run the container in the background and return the container ID;
#- i: run the container in interactive mode, usually with - t;
#- t: reassign a pseudo input terminal to the container, usually used at the same time as - i;
#-- name = "nginx LB": specify a name for the container;
#-- DNS 8.8.8.8: Specifies the DNS server used by the container, which is consistent with the host by default;
#-- DNS search [example.com](http://example.com/): Specifies the DNS search domain name of the container, which is the same as the host by default;
#- h "mars": Specifies the hostname of the container;
#- e username="ritchie": set environment variables;
#-- env file = []: read environment variables from the specified file;
#-- cpuse = "0-2" or -- cpuse = "0,1,2": bind the container to the specified CPU to run;
#- m: set the maximum memory used by the container;
#-- net="bridge": Specifies the network connection type of the container, and supports four types: bridge/host/none/container;
#-- link = []: add a link to another container;
#-- expose = []: open a port or a group of ports

Download the portal image

#Query the current port images
docker search portainer


#Select the first one to download the image
docker pull docker.io/portainer/portainer

Running the portal


docker run -d -p 9000:9000 
    --restart=always 
    -v /var/run/docker.sock:/var/run/docker.sock 
    --name prtainer-test 
    docker.io/portainer/portainer

The statement associates the 9000 port in the container with the 9000 port of the host, and names the container container container test. After executing the command, use the machine IP:PORT to access the container.



Access: http://IP:9000

To log in for the first time, you need to register the user and set the password for the admin user

Select local for stand-alone version, and click Connect to connect to local docker

You can see it when you come in. Here are some pictures. How do you feel


Tags: Linux Docker yum CentOS DNS

Posted on Mon, 13 Apr 2020 07:16:55 -0700 by quasiman