Can't remember the docker command? No hurry, docker graphical management tool Portainer to help you

What is docker? If you do n’t know, go to Google yourself. Many people have trouble with docker because there are many commands to remember. But the development of IT technology is so amazing, this non-graphical interface management tool is coming, today we introduce Portainer, a relatively mature, stable, and easy-to-use docker graphical management tool.

Docker basic environment

Use the wget tool to download the yum source from the 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 up boot

systemctl start docker
systemctl enable docker

Modify the docker image source-this way docker pull speed will be very fast

Add the following parameters in the /etc/docker/daemon.json file (new if there is no such file)


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

Service restart:


systemctl daemon-reload
systemctl restart docker


Common docker commands

Find Centos image file in Docker

docker search centos

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

docker pull centos

View the image file 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 containers (only stopped containers can be deleted)

docker rm container ID

Force delete container

docker rm -f container ID

删除镜像文件

docker rmi 镜像文件ID

获取容器信息

docker inspect 镜像ID

查看容器IP地址

docker inspect '容器ID' |grep IPAddress

查看容器映射端口

docker port 容器ID

创建容器

docker run
# -a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项;
# -d: 后台运行容器,并返回容器ID;
# -i: 以交互模式运行容器,通常与 -t 同时使用;
# -t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
# --name="nginx-lb": 为容器指定一个名称;
# --dns 8.8.8.8: 指定容器使用的DNS服务器,默认和宿主一致;
# --dns-search [example.com](http://example.com/): 指定容器DNS搜索域名,默认和宿主一致;
# -h "mars": 指定容器的hostname;
# -e username="ritchie": 设置环境变量;
# --env-file=[]: 从指定文件读入环境变量;
# --cpuset="0-2" or --cpuset="0,1,2": 绑定容器到指定CPU运行;
# -m :设置容器使用内存最大值;
# --net="bridge": 指定容器的网络连接类型,支持 bridge/host/none/container: 四种类型;
# --link=[]: 添加链接到另一个容器;
# --expose=[]: 开放一个端口或一组端口

下载Portainer镜像

# 查询当前有哪些Portainer镜像
docker search portainer


# 选择第一个,下载镜像
docker pull docker.io/portainer/portainer

运行Portainer


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

该语句用宿主机9000端口关联容器中的9000端口,并给容器起名为portainer-test。执行完该命令之后,使用该机器IP:PORT即可访问Portainer



访问方式:http://IP:9000

首次登陆需要注册用户,给admin用户设置密码

单机版这里选择local即可,选择完毕,点击Connect即可连接到本地docker

进来之后就可以看到了,下面放几张图,自己感受


Guess you like

Origin blog.51cto.com/xqtesting/2487008
Recommended