ã¯ããã«
- ãªãã£ã·ã£ã«ã®
docker
ã®ã¯ã©ã¤ã¢ã³ããMacOS X
ããã使ããããã«ãªã£ããããã®ã§è©¦ãã¦ã¿ã - ãªã¢ã¼ãã§ç¨¼åãã¦ãã
Docker
ãµã¼ãã¼ï¼Docker
ãµã¼ãã¼ã¨ããè¨ãæ¹ã§æ£ãããããããªããã©ï¼
åè
æºå
ç°å¢
試ãã¦ç°å¢ã¯ä»¥ä¸ã®ã¨ããã
ãã¹ãå | OS | docker | |
---|---|---|---|
ã¯ã©ã¤ã¢ã³ã | docker-client | MacOS X Marvericks | Docker version 0.7.4, build 010d74e |
ãµã¼ãã¼ | docker-server | Ubuntu 13.04 | Docker version 0.7.2, build 28b162e |
docker ã¯ã©ã¤ã¢ã³ã
boxen
ã使ã£ã¦ã¤ã³ã¹ãã¼ã«ããã®ã§ our-boxen/modules/people/manifests/${GIHUBID}.pp
ã以ä¸ã®ããã«è¿½å ããã
homebrew::tap { 'homebrew/binary': } package { 'homebrew/binary/docker' : require => Homebrew::Tap["homebrew/binary"] }
ã¤ã³ã¹ãã¼ã«å¾ãdocker -v
ããã¨ä»¥ä¸ã®ããã«åºåãããã
Docker version 0.7.4, build 010d74e
ããããã£ãã¼ï¼
docker ãµã¼ãã¼
ãµã¼ãã¼å´ã¨ãªã Ubuntu 13.04
ã«ã¤ã³ã¹ãã¼ã«ããã¦ãã docker
ã®è¨å®ã«ã¤ã㦠/etc/init/docker.conf
ã以ä¸ã®ããã«ä¿®æ£ããã
--- docker.conf.original 2014-01-25 14:28:09.769424260 +0900 +++ docker.conf 2014-01-25 14:28:48.173423611 +0900 @@ -11,5 +11,5 @@ if [ -f /etc/default/$UPSTART_JOB ]; then . /etc/default/$UPSTART_JOB fi - "$DOCKER" -d $DOCKER_OPTS + "$DOCKER" -d $DOCKER_OPTS -H=tcp://0.0.0.0:4243/ end script
ä¿®æ£å¾ãsudo docker stop && sudo docker start
ã§åèµ·åãè¡ãã
æ©é使ã
æ©éãdocker
ã¯ã©ã¤ã¢ã³ãã使ã£ã¦ã¿ãã
docker pull ãã¦ã¿ã
以ä¸ã®ããã«å®è¡ããã
docker pull -H=tcp://docker-server:4243 inokappa/wheezy-7.2-basic
以ä¸ã®ããã«åºåããã³ã³ããã¤ã¡ã¼ã¸ã®ãã¦ã³ãã¼ããéå§ãããã
ããã ãã§ãæåã
docker run ãã¦ã¿ã
æ¯å -H=tcp://docker-server:4243
ãæå®ããã®ã¯é¢åãªã®ã§ã以ä¸ã®ããã«ç°å¢å¤æ°ã«è¨å®ãã¦ãããã¨ãã©ã¼*1ã
export DOCKER_HOST="tcp://docker-server:4243"
è¨å®ãããæ¹ã㦠docker run
ãã¦ã¿ãã
docker run -t -i inokappa/wheezy-7.2-basic /bin/bash
以ä¸ã®ããã«è¦äºã«èµ·åããã
ããããããããã¼ã«ã«ã§ã³ã³ãããèµ·åãã¦ãããã®ããã ...ã
docker build ãã¦ã¿ã
以ä¸ã®ããã« Dockerfile
ãæ¸ãã¦ã³ã³ãããä½ã£ã¦ã¿ãã
cat << EOT >> Dockerfile FROM inokappa/wheezy-7.2-basic # MAINTAINER YOHEI KAWAHARA inokappa # RUN apt-get update RUN apt-get -y install sudo openssh-server # RUN mkdir -p /var/run/sshd RUN useradd -d /home/sandbox -m -s /bin/bash sandbox RUN echo sandbox:sandbox | chpasswd RUN echo 'sshuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # EXPOSE 22 CMD ["/usr/sbin/sshd","-D"] EOT
ããã¦ãdocker build
ãå®è¡ããã
docker build -t inokappa/openssh .
æ«ãããã¨ã³ã³ãããåºæ¥ä¸ããã
ï¼ç¥ï¼ Step 9 : EXPOSE 22 ---> Running in 26d6563bf3ae ---> 4e007fad243d Step 10 : CMD ["/usr/sbin/sshd","-D"] ---> Running in 803c1a7d8e13 ---> 620584d6c54f
åºæ¥æ ã確èªãã¦ãããã
ã³ã³ããã« SSH ã«ãã°ã¤ã³ãã¦ã¿ã
次㫠docker build
ããã³ã³ããã« SSH
ã§ãã°ã¤ã³ãã¦ã¿ããã®ã§ä»¥ä¸ã®ããã«ãã¦ã³ã³ãããèµ·åããã
docker run -d -p 22 inokappa/openssh
èµ·åãã㨠${Docker_ID}
ãåºåããã®ã§æ§ãã¦ãããèµ·åã®ç¢ºèªã¯ docker inspect ${Docker_ID}
ã docker ps
ã§ç¢ºèªãããä»åããµã¼ãã¼ã¨ã¯ã©ã¤ã¢ã³ãããµã¼ãã¼å
ã§èµ·åãã¦ããã³ã³ããã¯ä»¥ä¸ã®ãããªç¶æ
ã«ãªã£ã¦ããã
ä¸è¨ã®ããã«ãªã£ã¦ããã®ã§ã³ã³ããã¸ã®ã¢ã¯ã»ã¹ã«éãã¦ã¯ docker ps
ã使ã£ã¦ã³ã³ããä¸ã§ç¨¼åãã¦ãã SSH
ãã¼ãã«ãã¤ã³ããã¦ãããã¼ãã確èªããã
docker ps
以ä¸ã®ããã«ãã¤ã³ãããã¦ãããã¼ãã確èªããã
以ä¸ã®ããã«ã¢ã¯ã»ã¹ããã
ssh sandbox@${docker-server} -p 49154
è¦äºã«ã¢ã¯ã»ã¹åºæ¥ãã
æå¾ã«
- Mac ãã docker ãã¤ã¸ããããã«ãªã£ãã®ã¯å¬ããï¼
- ããè¨ãã°ãkitchen-docker ããªã¢ã¼ãã®
docker
ä¸ã®ã³ã³ããã§ãã¹ããèµ°ã£ã¦ãããªã¼
*1:better