LoginSignup
9
10

More than 5 years have passed since last update.

Docker for MacをいれてMacでubuntuが使えるようにしてみる

Posted at

オリジナル仮想通貨を作ってみようと本を読みながらやってたらどうやらubuntuでしか実行できないコマンドがあったのでdocker for macでubuntu環境を作ってみた。

Docker for Macをインストール

公式ページからインストール。
※ダウンロードするためにDockerIDが必要っぽいのでない場合は作る。スクリーンショット 2018-07-16 17.33.57.png

Dockerを起動

スクリーンショット 2018-07-16 17.37.17.png

ダウンロードしたファイルをダブルクリックすると「アプリケーションディレクトリにドラック&ドロップしてね」みたいなウィンドウが出てくるので言われるがままやる。

スクリーンショット 2018-07-16 17.39.22.png

アプリケーションディレクトリに移動していることを確認したら、実行してみる。

スクリーンショット 2018-07-16 17.40.09.png

するとなんかかわいい感じの画面が出てきて、上の部分にあるステータスが
Docker is now up and running!
になるので、ターミナルでコマンドを実行してみる。
$ docker version
すると結果が返ってきたので本当に動いてるっぽいことがわかる。

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:13:02 2018
 OS/Arch:      darwin/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:22:38 2018
  OS/Arch:      linux/amd64
  Experimental: true

hello-worldイメージから起動する

$docker run hello-world
ためしにやってみた。
ローカルにないと勝手に取りに行ってインストール、起動してくれる。

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

ubuntuを起動する

docker run -it ubuntu bash

-itはコンテナを作ってログインするオプション
最後のbashはbashを起動

Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6b98dfc16071: Pull complete
4001a1209541: Pull complete
6319fc68c576: Pull complete
b24603670dc3: Pull complete
97f170c87c6f: Pull complete
Digest: sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d
Status: Downloaded newer image for ubuntu:latest
root@6cf2a65ffc5f:/#

こんな感じでroot権限でログインした状態になってるので成功。

9
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
9
10