Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
88
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Ubuntu に docker と docker-compose を入れる

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

めでたし。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
88
Help us understand the problem. What are the problem?