ubuntu 16.04 docker安裝 跟helloworld docker
本篇文章是根據docker官網文件所編寫,幫助大家建立docker環境。
https://docs.docker.com/engine/getstarted/step_one/#docker-for-linux
https://docs.docker.com/engine/getstarted/linux_install_help/
1.curl 跟wget 之後將會用來抓取安裝shell檔,所以要先安裝起來。
sudo apt-get install curl wget
2. 抓取docker安裝文件並執行。
curl -fsSL https://get.docker.com/ | sh
3.啟動docker 服務於背景
sudo systemctl start docker
4.安裝並啟動 docker image,因為在本地端沒有image檔就會去跟網路抓。 docker run hello-world
smarturine@smarturinebagUbuntu:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
: Pull complete
Digest:
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
5.確認docker有在執行
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4df94953b35 hello-world "/hello" 15 minutes ago Exited (0) 15 minutes ago compassionate_shannon
有顯示出來就代表成功了~!