LoginSignup
1
1

More than 5 years have passed since last update.

Vagrant Ubuntu18.04(ubuntu/bionic64) へ docker-ce、docker-compose をインストール

Last updated at Posted at 2018-09-09

これは何?

  • Vagrant の Ubuntu18.04(ubuntu/bionic64) へ、docker、docker-compose をインストールした際のメモです。

参考URL

Get Docker CE for Ubuntu | Docker Documentation
https://docs.docker.com/install/linux/docker-ce/ubuntu/

Install Docker Compose | Docker Documentation
https://docs.docker.com/compose/install/

インストール実行

  • vagrant ssh でログインし、以下をコピー&ペーストで実行
(
  set -x
  set -e

  sudo apt -y install curl

  # *** docker install ***

  # 公式の開発環境用の簡単インストールスクリプトを使用
  # see https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script
  curl -fsSL https://get.docker.com -o get-docker.sh
  sudo sh get-docker.sh

  # カレントユーザをdockerグループの所属とする(sudoつけなくてもdockerコマンドが動くようにする)
  sudo usermod -aG docker $USER

  # バージョン確認
  docker --version
  sudo docker version

  # *** docker-compose install ***
  sudo curl -L \
    https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) \
    -o /usr/local/bin/docker-compose
  sudo chmod +x /usr/local/bin/docker-compose

  # バージョン確認
  docker-compose --version

) 2>&1 | tee $(date '+%Y%m%d-%H%M%S')_docker_install.log

動作確認

  • (先に設定したグループを有効にする為) 一旦ログアウトして、vagrant ssh で再ログインして、以下実行
# Docker バージョン確認
vagrant@ubuntu-bionic:~$ docker --version
Docker version 18.06.1-ce, build e68fc7a
vagrant@ubuntu-bionic:~$

# 試しに公式の hello-world コンテナ実行
vagrant@ubuntu-bionic:~$ docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
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/get-started/

vagrant@ubuntu-bionic:~$

メモ

  • Ubuntu(linux kernel 4 以上)は、ストレージドライバのデフォルトは、overlay2
1
1
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
1
1