首页  

docker安装和使用     所属分类 docker 浏览量 3289
yum install -y docker


yum list installed | grep docker

docker.x86_64                        2:1.13.1-94.gitb2f74b2.el7.centos @extras  
docker-client.x86_64                 2:1.13.1-94.gitb2f74b2.el7.centos @extras  
docker-common.x86_64                 2:1.13.1-94.gitb2f74b2.el7.centos @extras  

启动docker服务
systemctl start docker

查看是否启动成功
systemctl status docker


docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE


docker search hello


docker pull hello-world 

docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              fce289e99eb9        4 months ago        1.84 kB


docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

docker ps  -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES


docker run hello-world 

查看正在运行的容器

docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES


docker ps  -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
c095be8a1523        hello-world         "/hello"            46 seconds ago      Exited (0) 45 seconds ago                       romantic_hopper

容器状态共有 7 种:created|restarting|running|removing|paused|exited|dead


删除镜像
docker rmi fce289e99eb9
Error response from daemon: conflict: unable to delete fce289e99eb9 (must be forced) - image is being used by stopped container c095be8a1523

再运行一次
docker run hello-world 

docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES
941b8a73340b        hello-world         "/hello"            About a minute ago   Exited (0) About a minute ago                       zealous_dubinsky
c095be8a1523        hello-world         "/hello"            4 minutes ago        Exited (0) 4 minutes ago                            romantic_hopper


先删除容器
docker rm 941b8a73340b
docker rm c095be8a1523

删除镜像

docker rmi fce289e99eb9
Untagged: docker.io/hello-world:latest
Untagged: docker.io/hello-world@sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
Deleted: sha256:af0b15c8625bb1938f1d7b17081031f649fd14e6b233688eea3c5483994a66a3



运行异常处理

docker run hello-world 
container_linux.go:235: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused \"Cannot set property TasksAccounting, or unknown property.\""
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:235: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused \"Cannot set property TasksAccounting, or unknown property.\"".

升级一下
yum update 

yum -y update 
升级所有包 ,升级软件和系统内核

yum -y upgrade
只升级所有包,不升级软件和系统内核

升级前
cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

升级后
CentOS Linux release 7.6.1810 (Core)

上一篇     下一篇
自旋锁要点及简单实例

rocketmq要点

Docker和K8S

docker设置镜像仓库

docker run 与 start的区别

docker commit命令使用