顯示具有 docker 標籤的文章。 顯示所有文章
顯示具有 docker 標籤的文章。 顯示所有文章

2015年11月12日 星期四

jekyll docker under windows


  1. Install Docker Toolbox
  2. Startup Docker Terminal
  3. Use Putty to login 192.168.99.100 docker/tcuser (Do not use the original windows Bash, it will cause problem when using $(pwd) in docker --volume parameter)
  4. cd /c/Users/yourname/Document/jekyll_site
  5. jekyll new .

docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll -it -p 0.0.0.0:4000:4000 jekyll/jekyll:pages jekyll new .

5. jekyll s --force_polling
6. Browse the page in host browser with http://192.168.99.100:4000

2015年1月26日 星期一

docker networking

http://www.dasblinkenlichten.com/docker-networking-101/

  1. By default, all container networks are hidden from the real network. Here’s a masquerade (hide NAT) rule for all container traffic.  This allows all of the containers to talk to the outside world (AKA the real network) but doesn’t allow the outside rule to talk back to the containers.
  2. docker run -it –rm –p 8080:80 busybox   If we run that command, we can see that iptables creates an associated NAT rule that forwards traffic destined for 8080 on the host (10.20.30.100 in this case) to port 80 on the container…  if the busybox container on docker1 wants to talk to the busybox container on docker2, it could only do so through an exposed port on the hosts network interface. 
  3. 在host中把icc=false,container之間就不會互聯,要在run時用--link參數

2014年11月9日 星期日

play docker on windows

1. Install boot2docker
Download the installer
https://github.com/boot2docker/windows-installer/releases
This will install boot2docker, VirtualBox and git for windows

2. Start the boot2docker
Execute "Git Bash"
$ boot2docker start
$ boot2docker ip
Using the ip address to login boot2docker vm

3. Using putty to login boot2docker vm
IP: (get from previous step)
port: 22
username: docker
password: tcuser

4. create a my-data container to share folder & a samba container
docker run -v /data --name my-data busybox true
docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba my-data
(you can access share file in /(boot2docker's ip)/data in host windows)

5. Run a ubuntu container
$ docker run -it --volumes-from=my-data ubuntu
$
(you will in the container, using ctrl+p ctrl+q to detach)

6. check all container status
$ docker ps -a
(container id will be list)

7. Attach previous ubuntu container
$ docker attach [Container ID]
(just key-in the few heading numbers of container ID is OK)

8. Start playing around in container (in container)
$ apt-get update
$ apt-get install xxxxx
$ exit
(Will back to boot2docker vm)

9. Commit the container to a image
$ docker commit [Contain ID] your_name/image_name:tag

10. List all docker images
$ docker images
(previous commit image will be list)

11. Run a new container on new created image
$ docker run -it --volumes-from=my-data your_name/image_name:tag
$ exit

12. Delete container
$ docker rm [Container ID]

13. Delete image
$ docker rmi [image_name]

14. Back to "Git Bash", save the status of boot2docker
$ boot2docker save
(running status of boot2docker vm is saved)

15. resume boot2docker vm
$ boot2docker up

2013年11月10日 星期日

Docker on Windows

Docker
目前只支援在Ubuntu下跑,若要在Windows下,可用VirtualBox搭配Vagrant使用
官方Install Document

1.首先把VirtualBox和Vagrant安裝起來

2. git clone docker and vagrant up
git clone https://github.com/dotcloud/docker.git
cd docker
vagrant up
vagrant up之後會有一台ubuntu vm被開啟來,docker daemon就在上面執行

3. 用putty登入127.0.0.1:2222
(ubuntu vm的port 22被vagrant自動bind到host的port 2222)
default user/password 是 vagrant/vagrant


4. 登入後 基本使用教學
sudo su
docker run -t -i ubuntu /bin/bash
跑ubuntu這個image,產生一個container,執行/bin/bash並進入interactive shell

5. 之後就是在container的環境了,用apt-get可以安裝軟體,Alt+P & Alt+Q sequence可以跳回host(ubuntu vm)而不會結束container,跳host之後可用docker attach 回去。

6. docker ps查看還在跑的container資訊,包括ID和port(docker run時用-p參數),docker ps -a可看全部

7. docker commit 可存下container成image,例如新安裝的軟體,方便下次直接run成新的container

8. 編寫Dockerfile可build新的image

9. docker images查看現在有的images

10. 若要讓vagrant bind ubuntu vm的port給host,在vagrant up之前要先set FORWARD_DOCKER_PORTS=True
(好像沒辦法正常up起來)

Best Practice