一半君的总结纸

听话只听一半君

docker常用命令备忘录

tl;dr

$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

# 手动启动
systemctl start docker.service

# 如果想每次自动启动
systemctl enable docker.service

# 在官网搜镜像
docker search opengrok

# 显示运行中的 containers
docker ps

# 显示所有 containers
docker ps -a

# 重命名 container
docker rename CONTAINER NEW_NAME


# 启动之前关闭的container
docker start -i <containner_id>

# 退出console,但是不停止container
ctrl-p ctrl-q

# 连进运行中的container
docker exec -it <containner_id> /bin/bash

# 删除image
docker rmi <image>

# 保存repo更改
sudo docker commit -m "cloned repo" travis tt

# delete <none> images
sudo docker images|grep none|awk '{print $3 }' | xargs sudo docker rmi

  • container删不掉
    $ sudo docker rm travis
    Error response from daemon: Driver devicemapper failed to remove root filesystem f3a602c137202b655dec363f52da6d5962831f3ff6096f51ed74bf3c6d81255b: devicemapper: Error running DeleteDevice dm_task_run failed
    

    解决方法(CentOS 7)

    sudo systemctl stop docker
    sudo thin_check /var/lib/docker/devicemapper/devicemapper/metadata
    sudo thin_check --clear-needs-check-flag /var/lib/docker/devicemapper/devicemapper/metadata
    sudo systemctl start docker
    
    
  • sed: warning: failed to set default file creation context to system_u:object_r:svirt_sandbox_file_t:s0:c111,c913: Permission deniedtravis@b3b96598752b
    

    待解决,不过似乎不影响sed的替换功能

参考:
docker专题(2):docker常用管理命令(上)
Docker dm_task_run failed error
阿里云部署Docker(6)—-解决删除镜像问题

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: