Create image in container
interactive mode
bash
sudo docker run -i -t centos /bin/bash
bash
touch hello.txt
bash
exit
You can check it
bash
sudo docker ps -a
Create image
27663a6f8fe8 is ID
bash
sudo docker commit 27663a6f8fe8 bibo/hello
You can check images.
bash
sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bibo/hello latest eb521b0050ad About a minute ago 193MB
You can login it again
bash
sudo docker run -i -t bibo/hello /bin/bash
check it again
bash
ls -la | grep hello
You can use Dockerfile in Vagrant which is for automatic run
bash
vi Dockerfile
Dockerfile
FROM centos
MAINTAINER taro yamada <taro.yamada@bibo.com.ph>
# RUN: It executes when it is built
RUN echo "now building..."
# CMD: It executes when it is running
CMD ["echo", "now running..."]
bash
sudo docker build -t bibobibo/echo .
Sending build context to Docker daemon 8.704kB
Step 1/4 : FROM centos
---> 36540f359ca3
Step 2/4 : MAINTAINER taro yamada <taro.yamada@bibo.com.ph>
---> Running in 1006acc178a8
---> a4edca0b8521
Removing intermediate container 1006acc178a8
Step 3/4 : RUN echo "now building..."
---> Running in a697adda2cd7
now building...
---> 5fbf0850aedc
Removing intermediate container a697adda2cd7
Step 4/4 : CMD echo now running...
---> Running in e96059bd9d52
---> 131d7bfb63ed
Removing intermediate container e96059bd9d52
Successfully built 131d7bfb63ed
Successfully tagged bibobibo/echo:latest
You can see it.
bash
sudo docker images | grep bibobibo
You can run it
bash
sudo docker run bibobibo/echo