LoginSignup
13
10

More than 5 years have passed since last update.

Homebrewを使ってDockerをMacにインストール

Posted at

Home brewを使ってDockerでHello worldを出すところまで。
何番煎じだよ感半端ないけどQiita投稿の練習もかねて


(前提)Home brewがインストールされていること
(環境)Mac OS High Sierra 10.13.1


Home brewでDockerをインストール

$ brew cask install docker
==> Satisfying dependencies
==> Downloading https://download.docker.com/mac/stable/19611/Docker.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask docker
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'.
🍺  docker was successfully installed!
$

dockerがインストールされたか確認してみる

$ docker --version
-bash: docker: command not found
$

あれ?エラーが出る。インストールできてない?
アプリを起動してみた

open /Applications/Docker.app

何やらMacの管理PWを聞かれるので入力。
できたっぽいので再度確認。

$ which docker
/usr/local/bin/docker
$ docker ps
Error response from daemon: Bad response from Docker engine
$

ちゃんとインストールできたみたいだけど、まだエラーが出るなぁ。
と思ったらdockerが起動中なだけだった。。。
気を取り直して再確認

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$ docker --version
Docker version 17.09.0-ce, build afdb6d4
$ docker-machine --version
docker-machine version 0.12.2, build 9371605
$ docker-compose --version
docker-compose version 1.16.1, build 6d1ac21
$

OK。できた

hello worldを動かしてみる

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
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.
    (amd64)
 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/

$

おー、動いた動いた。
ローカルにはないのでDocker Hubから持ってきてくれているみたい。

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              f2a91732366c        12 days ago         1.85kB
$

これにて環境構築完了!!

13
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10