Created
November 25, 2014 23:52
-
-
Save mapyo/03c484c50f876e22db0f to your computer and use it in GitHub Desktop.
DockerfileでADDする時は~が使えない ref: http://qiita.com/mapyo/items/a0f1dbf311e7e4ee1c87
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ boot2docker -v | |
Boot2Docker-cli version: v1.3.1 | |
$ docker -v | |
Docker version 1.3.1, build 4e9bbfa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:centos6 | |
MAINTAINER Mapyo | |
# Create vagrant user | |
RUN groupadd vagrant | |
RUN useradd vagrant -g vagrant | |
# Change user | |
USER vagrant | |
WORKDIR /home/vagrant | |
ENV HOME /home/vagrant | |
ADD test.txt ~/test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 7 : ADD test.txt ~/test.txt | |
---> cda6ac3b2db4 | |
Removing intermediate container 102d36aa40e9 | |
Successfully built cda6ac3b2db4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build時のコマンド | |
$ docker build -t test . | |
# コンテナを起動 | |
$ docker run -i -t --name hoge test:latest /bin/bash | |
# 確認作業 | |
$ pwd | |
/home/vagrant | |
$ ls -la | |
total 24 | |
drwx------ 2 vagrant vagrant 4096 Nov 24 23:07 . | |
drwxr-xr-x 4 root root 4096 Nov 24 23:07 .. | |
-rw------- 1 vagrant vagrant 20 Nov 24 23:08 .bash_history | |
-rw-r--r-- 1 vagrant vagrant 18 Oct 16 14:56 .bash_logout | |
-rw-r--r-- 1 vagrant vagrant 176 Oct 16 14:56 .bash_profile | |
-rw-r--r-- 1 vagrant vagrant 124 Oct 16 14:56 .bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ADD test.txt /home/vagrant/test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build -t test . | |
$ docker rm hoge | |
$ docker run -i -t --name hoge test:latest /bin/bash | |
# コンテナの中 | |
$ ls -la | |
total 24 | |
drwx------ 2 vagrant vagrant 4096 Nov 24 23:16 . | |
drwxr-xr-x 4 root root 4096 Nov 24 23:16 .. | |
-rw-r--r-- 1 vagrant vagrant 18 Oct 16 14:56 .bash_logout | |
-rw-r--r-- 1 vagrant vagrant 176 Oct 16 14:56 .bash_profile | |
-rw-r--r-- 1 vagrant vagrant 124 Oct 16 14:56 .bashrc | |
-rw-r--r-- 1 root root 11 Nov 24 21:44 test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ADD test.txt /home/vagrant/test.txt | |
USER root | |
RUN chown vagrant:vagrant ~/test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build -t test . | |
$ docker rm hoge | |
$ docker run -i -t --name hoge test:latest /bin/bash | |
# コンテナの中 | |
$ ls -la | |
total 24 | |
drwx------ 2 vagrant vagrant 4096 Nov 24 23:19 . | |
drwxr-xr-x 5 root root 4096 Nov 24 23:19 .. | |
-rw-r--r-- 1 vagrant vagrant 18 Oct 16 14:56 .bash_logout | |
-rw-r--r-- 1 vagrant vagrant 176 Oct 16 14:56 .bash_profile | |
-rw-r--r-- 1 vagrant vagrant 124 Oct 16 14:56 .bashrc | |
-rw-r--r-- 1 vagrant vagrant 11 Nov 24 21:44 test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:centos6 | |
MAINTAINER Mapyo | |
# Create vagrant user | |
RUN groupadd vagrant | |
RUN useradd vagrant -g vagrant | |
# Change user | |
USER vagrant | |
WORKDIR /home/vagrant | |
ENV HOME /home/vagrant | |
ADD test.txt /home/vagrant/test.txt | |
USER root | |
RUN chown vagrant:vagrant ~/test.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment