LoginSignup
2
2

More than 5 years have passed since last update.

MacOS上にVagrantで立ち上げたUbuntu上にDockerを入れてみる

Posted at

環境

MacOS Sierra 10.12.6

ドットインストールの動画を参考に。
https://dotinstall.com/lessons/basic_docker/27701

VagrantでUbuntuを立ち上げ

http://www.vagrantbox.es/
からイメージを取得。名前はOfficial Ubuntu 14.04 daily Cloud Image amd64 (Development release, No Guest Additions)
対応するURLをコピーしてくる。

適当にプロジェクト用のディレクトリを作成し、Boxを追加。
Boxにはtrusty64という名前をつける。
(名前は多分なんでもいいけど、ubuntuのバージョン14がtrustyと呼ばれているらしい)

$ mkdir MyVagrant
$ cd MyVagrant
$ vagrant box add trusty64 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

Docker用のディレクトリを作成し、そこでvagrant立ち上げ。

$ mkdir Docker
$ cd Docker
$ vagrant init trusty64

Vagrantfileができるので、それを編集。

$ vim Vagrantfile

ipアドレスを変えたいんですって。
35行目あたり?の設定のところをコメントアウト外して、

config.vm.network "private_network", ip: "192.168.55.44"

とする。
(これって必ず必要なんだろうか。)

で、

$ vagrant up

として起動。

Ubuntuの上にDockerを立ち上げる

どうやらDockerのインストール手順が、動画の内容とは変わっているらしい。(2018.01.27現在)

https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce
を参考にDocker ceなるものを入れていく。

リポジトリをセットアップするらしい。

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

次にDOCKER CEをインストール

$ sudo apt-get update
$ sudo apt-get install docker-ce

プロダクションシステム上では、必ずしも最新のバージョン使わないほうがいいんじゃないって書いてあるけど、とりあえず最新っぽいやつのバージョン指定して入れておく。

$ apt-cache madison docker-ce

で使えるバージョンがリスト表示されるから、その中で適当なやつ指定する。

$ sudo apt-get install docker-ce=17.12.0~ce-0~ubuntu

テスト的なやつ

sudo docker run hello-world

僕はsudo docker run hello-worldというメッセージとともに20行くらいつらつらとメッセージが表示されました。
多分、インストール成功したということでしょう!

2
2
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
2
2