Docker: Create Image from Container
2016-07-31 23:50
453 查看
Docker: Create Image from Container
I’m going to create my own image from a running container for further sharing. So, I’m planning to get a container as base, run it, commit as Image, export image as a file and share with friends, and finally be loaded by them.
Here I list the steps:
and make it executable.
Terminal message:
Now we get container id:
Terminal text:
So we get the image locally
Terminal text:
Then image can be loaded in local repository.
I’m going to create my own image from a running container for further sharing. So, I’m planning to get a container as base, run it, commit as Image, export image as a file and share with friends, and finally be loaded by them.
Here I list the steps:
Base container
Get a base Image
docker pull centos
Run a base Container
docker run -it centos /bin/bash
Update Container
Modify Container
I will create a file/usr/local/bin/echo, with content:
#!/bin/bash echo "hi, $@"
and make it executable.
# chmod a+x echo
See Container status
docker ps -a
Terminal message:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c71580983e83 centos "/bin/bash" 44 seconds ago Exited (0) 3 seconds ago echo
Now we get container id:
c71580983e83
Create Image
Commit Container as Image
Save the image asecho:v1, which name
echowith tag
v1.
docker commit -m "echo container" -a "wang xiaoqiang" c71580983e83 echo:v1
See the images
docker images
Terminal text:
REPOSITORY TAG IMAGE ID CREATED SIZE echo v1 511b808ecb31 12 seconds ago 196.7 MB
So we get the image locally
511b808ecb31in name
echo:v1.
Use Image
Save Image
docker save echo:v1 >echo-v1.tar
Load Image
docker load < echo-v1.tar
Terminal text:
8db4df206a2d: Loading layer [==================================================>] 5.12 kB/5.12 kB
Then image can be loaded in local repository.
相关文章推荐
- Docker - How to create a custom database from docker mysql image
- 解决:Call to undefined function imagecreatefromjpeg;JPEG Support enabled却不成正常压缩裁剪jpeg图片
- imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 1 extraneous bytes be
- Docker:Error response from daemon: Cannot restart container lnmp: oci runtime error: container_linux
- imagecreatefrom php图片处理
- docker container image应该具有的拍错工具
- [PHP] GD库(五):载入图像 imagecreatefrom_gif_jpeg_png 系列函数
- PHP 载入图像 imagecreatefrom_gif_jpeg_png 系列函数
- php Fatal error: Call to undefined function imagecreatefromjpeg()
- imagecreatefrompng函数引起的问题
- Docker三个基本概念镜像(Image)容器(Container)仓库(Repository)
- Error response docker - from daemon: Cannot start container test: Error getting container
- Dockerfile -> Image -> Container
- [Docker] Container & image (docker run)
- PHP imagecreatefrombmp 从BMP文件或URL新建一图像
- 【Docker】构建mysql的image和container
- 制作一个python-docker image and run a container!
- Create an ISO Image from a source CD or DVD on ubuntu
- docker containerd 中的create 容器操作
- 16. 31. 1. Create Disabled Image from GrayFilter