LoginSignup
0
1

More than 5 years have passed since last update.

set up docker and run httpd in 2 vagrant machines. 3

Last updated at Posted at 2017-08-02

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

前はこちら
続きはこちら

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1