docker doc
docker on ubuntu
use local registry
- edit file /etc/default/docker
>sudo vim /etc/default/docker ## add below line DOCKER_OPTS="--insecure-registry 10.35.59.44:5000" >sudo service docker restart
docker version
yufei@yufeidesktop:~$ sudo docker version Client: Version: 1.8.2 API version: 1.20
docker restart
yufei@yufeidesktop:~$ sudo service docker restart docker stop/waiting docker start/running, process 32406
>sudo service docker status >sudo service docker stop >sudo service docker start
docker begin
- install docker on mac
- docker run hello-world
>docker run hello-world
- docker run docker/whalesay cowsay boo
>docker run docker/whalesay cowsay boo
- docker images - list all images on your local system
bash-3.2$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker-whale latest 614b79d97fb0 7 days ago 274 MB yren/docker-whale latest 614b79d97fb0 7 days ago 274 MB hello-world latest af340544ed62 4 weeks ago 960 B docker/whalesay latest fb434121fc77 3 months ago 247 MB
write a docker file
- mkdir mydockerbuild
$ mkdir mydockerbuild
$ cd mydockerbuild
$ touch Dockerfile
$vi Dockerfile
- add blow content to Dockerfile
FROM docker/whalesay:latest RUN apt-get -y update && apt-get install -y fortunes CMD /usr/games/fortune -a | cowsay
- build your new image by typing the "docker build -t docker-whale ."
docker build -t docker-whale .
publish image to docker hub
- login https://hub.docker.com
- tag and publish image
docker images
find image id for "docker-whale"
$ docker tag 7d9495d03763 maryatdocker/docker-whale:latest $ docker login --username=maryatdocker --password=uydfiad77fad --email=mary@docker.com $ docker push maryatdocker/docker-whale
pull new image
- docker rmi
You can use an ID or the name to remove an image.
$ docker rmi -f 7d9495d03763 $ docker rmi -f docker-whale
docker ps
- list all container
docker ps -a
- remove docker container
docker rm <container>
- remove all stop docker container
sudo docker ps -a | grep 'Exited' | awk '{print $1}' | xargs --no-run-if-empty sudo docker rm
- remove image
docker rmi <image>
docker pull
- docker pull image
sudo docker pull 10.35.59.44:5000/rcom/jre:8
docker run
docker run --name
#name container jdk8, this can prevent start same name container multi times sudo docker run -it --name=jdk8 10.35.59.44:5000/rcom/jre:8 /bin/bash