LoginSignup
82
86

More than 5 years have passed since last update.

Ubuntu に docker と docker-compose を入れる

Last updated at Posted at 2017-04-14

EC2 のインスタンスに気軽に docker いれようと思ったら、Amazon Linux だと入る docker version が古かったので、Ubuntu にしてみました。

docker をいれる

Docker CE (Community Edition) を入れます。

Ref. https://docs.docker.com/engine/installation/linux/ubuntu/#os-requirements

$ sudo apt-get update
sudo: unable to resolve host ip-**-**-**-**

いきなり unable がでたので、/etc/hosts を書き換えて以下のようにする。

127.0.0.1 localhost ip-**-**-**-**
$ sudo apt-get update

$ sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual

# Install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

# Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Check architecture
$ arch
x86_64

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

$ sudo apt-get update

$ sudo apt-get install docker-ce

$ docker -v
Docker version 17.03.1-ce, build c6d412e

$ # sudo なしで、docker できるように以下を叩いて、いったん ubuntu から抜ける
$ # Ref. https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
$ sudo usermod -aG docker $(whoami)

$ docker info

めでたし。

docker-compose をいれる

すでに力尽きてきたのですが、がんばって docker-compose をいれます。

$ docker-compose -v
The program 'docker-compose' is currently not installed. You can install it by typing:
sudo apt install docker-compose

Ref. https://docs.docker.com/compose/install/

ここで、バージョンを確認

$ sudo -i
# curl -L "https://github.com/docker/compose/releases/download/1.12.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# chmod +x /usr/local/bin/docker-compose
# exit
$ docker-compose -v
docker-compose version 1.12.0, build b31ff33

めでたし。

82
86
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
82
86