Skip to content

Instantly share code, notes, and snippets.

@piksel
Created July 8, 2021 16:45
Show Gist options
  • Save piksel/2d66c663bb9833285062fe1a573baef8 to your computer and use it in GitHub Desktop.
Save piksel/2d66c663bb9833285062fe1a573baef8 to your computer and use it in GitHub Desktop.
Change in containers created by docker compose
# Using docker subcommand `compose`
$ docker compose up
$ docker container inspect kafka -f ' Image: {{ .Image }}{{"\n"}}Config.Image: {{.Config.Image}}'
Image: sha256:d694642b6bef4693082bd6192d923f37af9e27ef15beef9de7d93a51d1a5d74d
Config.Image: sha256:d694642b6bef4693082bd6192d923f37af9e27ef15beef9de7d93a51d1a5d74d
# Using standalone `docker-compose`
$ docker-compose up
$ docker container inspect kafka -f ' Image: {{ .Image }}{{"\n"}}Config.Image: {{.Config.Image}}'
Image: sha256:d694642b6bef4693082bd6192d923f37af9e27ef15beef9de7d93a51d1a5d74d
Config.Image: bitnami/kafka:latest
@piksel
Copy link
Author

piksel commented Jul 8, 2021

Tried to check if this was the case on non-desktop version of docker...

WSL2 (using Desktop):

WSL2❯ docker --version
Docker version 20.10.7, build f0df350

WSL2❯ docker compose

Usage:  docker compose [OPTIONS] COMMAND
[...]

Ubuntu Server 20.04 LTS (with latest docker from their own repo):

$ docker --version
Docker version 20.10.7, build f0df350

$ docker compose
docker: 'compose' is not a docker command.
See 'docker --help'

😩

@piksel
Copy link
Author

piksel commented Jul 8, 2021

Sooo, it's apparently in beta?
https://docs.docker.com/compose/cli-command/

Fine, let's install it using this totally non-sketchy script:
https://docs.docker.com/compose/cli-command/#install-on-linux

$ curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Running checks...
100  5982  100  5982    0     0  31156      0 --:--:-- --:--:-- --:--:-- 31156
Checks passed!
Downloading CLI...
Downloaded CLI!
Installing CLI...
Done!

Okay, now let's see...

$ docker compose
docker: 'compose' is not a docker command.
See 'docker --help'

Okay, maybe it didn't update the PATH correctly, let's manually run the binary that the script downloads:

$ curl -s 'https://api.github.com/repos/docker/compose-cli/releases/latest' | grep "browser_download_url.*docker-linux-amd64" | cut -d : -f 2,3
"https://github.com/docker/compose-cli/releases/download/v1.0.17/docker-linux-amd64"

$ curl -OL https://github.com/docker/compose-cli/releases/download/v1.0.17/docker-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   626  100   626    0     0   9630      0 --:--:-- --:--:-- --:--:--  9630
100 57.6M  100 57.6M    0     0  34.9M      0  0:00:01  0:00:01 --:--:-- 40.5M

$ ./docker-linux-amd64 compose
docker: 'compose' is not a docker command.
See 'docker --help'

(╯°Д°)╯ ︵🐋

@piksel
Copy link
Author

piksel commented Jul 8, 2021

Okay, finally got it working after finding the last paragraph in the docker/compose-cli README

So, the v1.* releases does not include docker compose. So... what are they? Go-versions of docker-compose? Nope, they are patched versions of the Docker CLI, adding another version field labeled Cloud integration...

$ ./docker-linux-amd64 version
Client: Docker Engine - Community
 Cloud integration: 1.0.17

But okay, downloading the latest pre-release v2.0.0-beta.6 and moving it into the cli-plugins folder:

$ curl -L -o ~/.docker/cli-plugins/docker-compose --create-dirs \
  'https://github.com/docker/compose-cli/releases/download/v2.0.0-beta.6/docker-compose-linux-amd64'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   634  100   634    0     0   3062      0 --:--:-- --:--:-- --:--:--  3062
100 24.2M  100 24.2M    0     0  17.5M      0  0:00:01  0:00:01 --:--:-- 27.6M

$ docker compose

Usage:  docker compose [OPTIONS] COMMAND
...

Finally!

$ docker compose up -d
[+] Running 1/1
 ⠿ Container dc-test_web_1  Started

$ docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS          PORTS                                       NAMES
fb0c2a735c38   4cdc5dd7eaad      "/docker-entrypoint.…"   18 minutes ago   Up 20 seconds   80/tcp                                      dc-test_web_1

No image tag, only ID. Well, at least it's consistent...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment