1. Installation
1.1 Mac
1.2 Centos
1.3 ubuntu 14.04 LTS
apt-get install docker.io를 하면 예전 버전이 인스톨 되므로 다음을 따라한다. For ones want to remove docker first
#!/bin/bash
sudo service docker stop
sudo apt-get remove lxc-docker
sudo apt-get autoremove
sudo apt-get update
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install lxc-docker
To verify
mkang@W10023:/etc/apt/sources.list.d$ docker --version
Docker version 1.7.1, build 786b29d
mkang@W10023:/etc/apt/sources.list.d$ sudo docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
2. Config
sudo usermod -aG docker ${USER}
sudo service docker restart
Log out and log back in
3. Use
3.1 check the version
mkang@W10023:~$ docker --version
Docker version 1.7.1, build 786b29d
mkang@W10023:~$ sudo docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
3.2 get the image
mkang@W10023:~$ sudo docker pull ubuntu:14.04.2
14.04.2: Pulling from ubuntu
2eaf0096818b: Already exists
dac7bccb8ac3: Already exists
389028aa9e91: Already exists
63e3c10217b8: Already exists
ubuntu:14.04.2: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:299d80c33faffebc09d35fed5a6ee6cf3baa30cc7c8ab019ba64b75855c6423a
Status: Downloaded newer image for ubuntu:14.04.2
3.3 print image
mkang@W10023:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04.2 63e3c10217b8 2 days ago 188.4 MB
ubuntu latest 63e3c10217b8 2 days ago 188.4 MB
3.4 docker run
mkang@W10023:~$ sudo docker run -i -t --name hello ubuntu /bin/bash
root@1849e8212590:/# whoami
-i : interactive mode
--name hello: name of the container
ubuntu: image to use
/bin/bash: command
3.5 print all container list
mkang@W10023:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1849e8212590 ubuntu "/bin/bash" About a minute ago Exited (0) 17 seconds ago hello
-a : shows stopped containers
3.6 restart stopped container
mkang@W10023:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
mkang@W10023:~$ sudo docker start hello
hello
mkang@W10023:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1849e8212590 ubuntu "/bin/bash" 3 minutes ago Up 5 seconds hello
3.7 restarting container
mkang@W10023:~$ sudo docker restart hello
hello
3.8 attach to the container
mkang@W10023:~$ sudo docker attach hello
root@1849e8212590:/#
3.9 running some command
mkang@W10023:~$ sudo docker exec hello echo "Hello World"
Hello World
3.10 stopping the container
mkang@W10023:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1849e8212590 ubuntu "/bin/bash" 8 minutes ago Up 53 seconds hello
mkang@W10023:~$ sudo docker stop hello
hello
mkang@W10023:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3.11 deleting container
mkang@W10023:~$ sudo docker rm hello
hello
mkang@W10023:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3.12 deleting image
mkang@W10023:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04.2 63e3c10217b8 2 days ago 188.4 MB
ubuntu latest 63e3c10217b8 2 days ago 188.4 MB
mkang@W10023:~$ sudo docker rmi ubuntu:latest
Untagged: ubuntu:latest
mkang@W10023:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04.2 63e3c10217b8 2 days ago 188.4 MB
4. Create from Dockerfile
mkang@W10023:~/_tmp_docker$ cat Dockerfile
FROM ubuntu:14.04.2
MAINTAINER Foo Bar [email protected]
RUN apt-get update
RUN apt-get install -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
RUN chown -R www-data:www-data /var/lib/nginx
VOLUME ["/data", "/etc/nginx/site-enabled", "/var/log/nginx"]
WORKDIR /etc/nginx
CMD ["nginx"]
EXPOSE 80
EXPOSE 443
5. How to Run your Own Private Docker Image Repository
https://blog.codecentric.de/en/2014/02/docker-registry-run-private-docker-image-repository/ https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-ubuntu-14-04