Cài Docker Compose trên Ubuntu (Linux)

Table of Contents

Cài Docker Compose trên Ubuntu (Linux)

Lỗi Unable to locate package docker-compose-plugin

Ban đầu mình cài với lệnh sudo apt install docker-compose-plugin, tuy nhiên bị lỗi sau:

Unable to locate package docker-compose-plugin

haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2,570 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,810 kB]
Fetched 4,632 kB in 7s (667 kB/s)
Reading package lists... Done
haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo apt-get install docker-compose-plugin
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker-compose-plugin
haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo apt install docker-compose-plugin
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker-compose-plugin

Mình cũng thử cài qua lệnh curl nhưng cũng không được

haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo curl -L "https://github.com/docker/compose/releases/download/2.5.1/docker-compose-$(uname -s)-$(uname -m)"  -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     9  100     9    0     0     20      0 --:--:-- --:--:-- --:--:--    20
haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose
haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo chmod +x /usr/bin/docker-compose
haugiang@hg-nn-web:/nongnghiep/docker/postgresql$ sudo docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'

Tìm cách cài Docker Compose

Mình làm theo cách này vì thấy khả thi nhất

https://stackoverflow.com/posts/47061271/timeline

I'm installing on a Raspberry Pi 3, with Raspbian 8. The curl method failed for me (got a line 1: Not: command not found error upon asking for docker-compose --version) and the solution of @sunapi386 seemed a little out-dated, so I tried this which worked:

First clean things up from previous efforts:

sudo rm /usr/local/bin/docker-compose
sudo pip uninstall docker-compose

Then follow this guidance re docker-compose on Rpi:

sudo apt-get -y install python-pip
sudo pip install docker-compose

For me (on 1 Nov 2017) this results in the following response to docker-compose --version:

docker-compose version 1.16.1, build 6d1ac219

Mình chạy với pip2 thì lỗi version của mình thấp quá, chạy pip3 thì lỗi không cài được

image

Cuối cùng mình upgrade pip lên

sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip

Rồi sau đó cài Docker Compose

sudo pip install docker-compose

Lúc này cài thành công, nhưng thử check version docker compose thì không chạy được

image

Thế là quay lại mình thử cài với ATP thử

sudo apt-get install docker-compose

Lúc này lại cài thành công, mình cài được mà cũng chưa biết chính xác sao cài được :') , ai biết coment bên dưới giải đáp hộ. Hên vãi =))

sudo docker-compose --version

image

Tham khảo

Leave a Reply

Your email address will not be published. Required fields are marked *