0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2 Ubuntu 20.04 にDocker, docker-composeを入れる

Last updated at Posted at 2021-07-14

Docker

事前準備。

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Docker公式のGPG公開鍵をインストール。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Dockerを入れる。

**********の所は自分のUbuntuユーザー名に書き換えてください。

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

# sudo systemctl enable docker
# ↑自動起動がうまくならない場合が…
# なので↓に変更
sudo echo "sudo service docker start" >> ~/.bashrc

sudo service docker start
sudo usermod -a -G docker **********

ターミナルを再起動する。

Dockerを動作確認してみる。

docker run hello-world

docker-compose

https://github.com/docker/compose/releases で最新バージョンの番号を調べる。

docker-composeを入れる。

*.**.*のところは、↑で調べたバージョン番号に書き換えてください。

sudo curl -L https://github.com/docker/compose/releases/download/*.**.*/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

docker-composeコマンドを動作確認してみる。

docker-compose --version
0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?