Docker for Mac
こちらからインストール
ターミナルで確認
~ $ docker --version
Docker version 1.13.1, build 092cba3
~ $ docker-compose --version
docker-compose version 1.11.1, build 7c5d5e4
~ $ docker --version
Docker version 1.13.1, build 092cba3
~ $ docker-machine --version
docker-machine version 0.9.0, build 15fd4c7
Docker version 1.13.1, build 092cba3
~ $ docker-compose --version
docker-compose version 1.11.1, build 7c5d5e4
~ $ docker --version
Docker version 1.13.1, build 092cba3
~ $ docker-machine --version
docker-machine version 0.9.0, build 15fd4c7
hello-world
~ $ docker run hello-world
docker: Cannot connect to the Docker daemon at tcp://192.168.59.103:2376. Is the docker daemon running?.
See 'docker run --help'.
docker: Cannot connect to the Docker daemon at tcp://192.168.59.103:2376. Is the docker daemon running?.
See 'docker run --help'.
エラー!?
sudo つけてみた、、、
~ $ sudo docker run hello-world
Password:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: 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/
Password:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: 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/
web server
~ $ docker run -d -p 80:80 --name webserver nginx
docker: Cannot connect to the Docker daemon at tcp://192.168.59.103:2376. Is the docker daemon running?. See 'docker run --help'.
docker: Cannot connect to the Docker daemon at tcp://192.168.59.103:2376. Is the docker daemon running?. See 'docker run --help'.
エラー!?
sudoつけてみた、、、
~ $ sudo docker run -d -p 80:80 --name webserver nginx
Password:
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
5040bd298390: Pull complete
31123d939af1: Pull complete
23f1bdd267a9: Pull complete
Digest:
Status: Downloaded newer image for nginx:latest
Password:
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
5040bd298390: Pull complete
31123d939af1: Pull complete
23f1bdd267a9: Pull complete
Digest:
Status: Downloaded newer image for nginx:latest
ブラウザで localhost みると、、、
オーケー!
プロセスみてみる、、、sudoつけてね
~ $ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e4134e2e67d nginx "nginx -g 'daemon ..." 17 minutes ago Up 16 minutes 0.0.0.0:80->80/tcp, 443/tcp webserver
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e4134e2e67d nginx "nginx -g 'daemon ..." 17 minutes ago Up 16 minutes 0.0.0.0:80->80/tcp, 443/tcp webserver
nginxが動いているね。
webserver を止めてみる、、、
~ $ sudo docker stop webserver
webserver
~ $ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ed0928c3844 hello-world "/hello" 7 minutes ago Exited (0) 7 minutes ago kind_bhabha
9e4134e2e67d nginx "nginx -g 'daemon ..." 19 minutes ago Exited (0) 9 seconds ago webserver
webserver
~ $ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ed0928c3844 hello-world "/hello" 7 minutes ago Exited (0) 7 minutes ago kind_bhabha
9e4134e2e67d nginx "nginx -g 'daemon ..." 19 minutes ago Exited (0) 9 seconds ago webserver
nginxがExitedしているね。
webserverのコンテナを削除してみる、、、
~ $ sudo docker rm -f webserver
webserver
~ $ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ed0928c3844 hello-world "/hello" 8 minutes ago Exited (0) 8 minutes ago kind_bhabha
webserver
~ $ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ed0928c3844 hello-world "/hello" 8 minutes ago Exited (0) 8 minutes ago kind_bhabha
削除されているね。
以上、
Get started with Docker for Mac
でした。
0 件のコメント:
コメントを投稿