Docker-1

Step 1 — Installing Docker
sudo apt-get update
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-get update
apt-cache policy docker-engine
sudo apt-get install -y docker-engine
sudo systemctl status docker

Step 2 — Executing the Docker Command Without Sudo (Optional)
sudo usermod -aG docker $(whoami)
sudo usermod -aG docker username

Step 3 — Using the Docker Command
docker [option] [command] [arguments]
docker
docker info

Step 4 — Working with Docker Images
docker run hello-world
docker search ubuntu
docker pull ubuntu
docker run ubuntu
docker images

Step 5 — Running a Docker Container
docker run -it ubuntu
apt-get update
apt-get install -y nodejs

exit

 

Step 6 — Committing Changes in a Container to a Docker Image

When you commit an image, the new image is saved locally, that is, on your computer. Later in this tutorial, you'll learn how to push an image to a Docker registry like Docker Hub so that it may be assessed and used by you and others.
docker commit -m "What did you do to the image" -a "Author Name" container-id repository new_image_name
docker commit -m "added node.js" -a "Sunday Ogwu-Chinuwa" d9b100f2f636 finid/ubuntu-nodejs
docker images


Step 7 — Listing Docker Containers
docker ps
docker ps -a
docker ps -l
docker stop container-id

Step 8 — Pushing Docker Images to a Docker Repository
docker login -udocker-registry-username
docker push docker-registry-username docker-image-name

两种方法让一个image发生update

(1)使用docker commit 将container的change写入到本地对应的image,然后 docker push 将本地image 推送到docker repo

(2)使用dockerfile去update一个image,然后docker push 将本地image 推送到docker repo

posted on 2016-11-14 10:44  chaseblack  阅读(134)  评论(0编辑  收藏  举报

导航