0%

Docker使用记录

Docker使用记录

inspect 查看镜像详细信息

1
docker inspect -f {{".Size"}} nginx

history 查看镜像历史信息

1
docker history --no-trunc nginx

Docker –volume 挂载时报错信息如下:

Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

出现此情况: 请检查是否使用boot2docker挂载了共享目录,是有使用了别名

docker run

-d 后台运行
-h 修改container终端HOST
-p 指定端口映射 本机(非docker)端口:container端口
-v 挂载目录 本机:container
--privileged 提权
--name container name
--restart=always 自动重启
--dns=ipaddr 指定dns
/run.sh 将运行 /usr/sbin/sshd -D

docker

安装 telnet
apt-get install xinetd telnetd

memcached
telnet 127.0.0.1 11211
stats items
stats cachedump 7 0
get testkey

镜像的导入导出

导出镜像
docker save -o centos7.tar centos
导入本地镜像
sudo docker load –input centos7.tar

查看数据库

1
docker exec -i mysql8 mysql --show-warnings --silent -uroot -p1234 -e "show databases"