拷贝容器镜像内的文件到容器外
例子拷贝nginx
容器镜像默认配置文件到容器外
话不多说,直接上脚本代码
#!/bin/bash
set -eux
__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}
# nginx:alpine 是镜像名称
container_id=$(docker create nginx:alpine) # returns container ID
docker cp $container_id:/etc/nginx/nginx.conf nginx.conf
docker cp $container_id:/etc/nginx/mime.types mime.types
docker cp $container_id:/etc/nginx/conf.d/default.conf default.conf
docker rm $container_id