启动docker服务
systemctl start docker
停止docker服务
systemctl stop docker
重启docker服务
systemctl restart docker
查看docker服务状态
systemctl status docker
设置开机启动docker服务
systemctl enable docker
设置关闭开机启动docker服务
systemctl disable docker
重载系统服务
systemctl daemon-reload
查看全部服务
systemctl list-unit-files --type service
搜索镜像
docker search hello-world
拉去镜像
docker pull hello-world
查看本地镜像
docker images
运行镜像
docker run hello-world
查看所有的容器
docker ps -a
查看
docker ps -no-trunc
停止
docker stop/start CONTAINERID
通过容器别名启动/停止
docker start/stop 容器别名
查看容器所有基本信息
docker inspect 容器别名
查看容器日志
docker logs 容器别名
查看容器所占用的系统资源
docker stats 容器别名
容器执行命令
docker exec 容器名 容器内执行的命令
登入容器的bash
docker exec -it 容器名 /bin/bash
容器的自动启动
--restart=always
设置容器主机名
--h x.xx.xx
设置容器使用的 DNS服务器
--dns xx.xx.xx.xx
DNS搜索设置
--dns-search
注入 hostname<>IP
--add-host hostname:IP
解析服务停止时自动删除
--rm
问题1
当关闭docker时候提示:Warning: Stopping docker.service, but it can still be activated by:
docker.socket
执行下面命令
systemctl stop docker.socket