Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Docker Compose version check more forgiving #1132

Closed
mowangjuanzi opened this issue Oct 30, 2021 · 20 comments
Closed

Make Docker Compose version check more forgiving #1132

mowangjuanzi opened this issue Oct 30, 2021 · 20 comments

Comments

@mowangjuanzi
Copy link

Version

21.10.0

Steps to Reproduce

  1. https://github.com/getsentry/onpremise.git
  2. sudo SENTRY_IMAGE=getsentry/sentry:21.10.0 ./install.sh

Expected Result

Install Success.

Actual Result

▶ Parsing command line ...

▶ Setting up error handling ...

▶ Checking minimum requirements ...
FAIL: Expected minimum docker-compose version to be 1.28.0 but found Docker Compose version v2.0.1

@mowangjuanzi
Copy link
Author

this is a docker-compose question ?

@chadwhitacre
Copy link
Member

@mowangjuanzi We recently started supporting both v1 and v2 of Docker Compose, it's possible you've found a bug in how we implement that. Can you debug this further? Look in install/check-requirements.sh and see how the environment variables are ending up in there.

@mowangjuanzi
Copy link
Author

i not found install/check-requirements.sh

but i found install/check-minimum-requirements.sh

$ docker version
Client: Docker Engine - Community
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:43:58 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:42:04 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
$ docker-compose version
Docker Compose version v2.0.1
$ git log -1
commit c16ae024dc3e8259b03679f950e80e1cbfb5dae8 (HEAD -> master, origin/master, origin/HEAD)
Author: Chad Whitacre <[email protected]>
Date:   Tue Nov 2 10:59:13 2021 -0400

    Fix #1079 - bug in reset.sh (#1134)
    
    We need $0 to evaluate as install.sh in order for check-requirements to
    work.
$ sh install/check-minimum-requirements.sh 
Checking minimum requirements ...
install/check-minimum-requirements.sh: 3: source: not found
docker: 'compose' is not a docker command.
See 'docker --help'
unknown flag: --short
See 'docker --help'.

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/home/mowangjuanzi/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/home/mowangjuanzi/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/home/mowangjuanzi/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/mowangjuanzi/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  app*        Docker App (Docker Inc., v0.9.1-beta3)
  builder     Manage builds
  buildx*     Build with BuildKit (Docker Inc., v0.6.3-docker)
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  scan*       Docker Scan (Docker Inc., v0.9.0)
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

install/check-minimum-requirements.sh: 17: Syntax error: "(" unexpected

@mowangjuanzi
Copy link
Author

$ echo $(docker-compose --version | sed 's/docker-compose version \(.\{1,\}\),.*/\1/')
Docker Compose version v2.0.1

@chadwhitacre
Copy link
Member

chadwhitacre commented Nov 4, 2021

i not found install/check-requirements.sh

but i found install/check-minimum-requirements.sh

Sorry, that's what I meant, yes. :)

Architectural Sidebar

sh install/check-minimum-requirements.sh

The non-executable files in install are designed to be sourced by install.sh, not run directly, hence the following output:

install/check-minimum-requirements.sh: 3: source: not found

Debugging the Problem

Going over your initial report more carefully, I see a clue:

Expected minimum docker-compose version to be 1.28.0 but found Docker Compose version v2.0.1

I hypothesize that the v in v2.0.1 is causing this check to fail:

https://github.com/getsentry/onpremise/blob/c16ae024dc3e8259b03679f950e80e1cbfb5dae8/install/check-minimum-requirements.sh#L24

And I hypothesize that the v is there because you're hitting this line:

https://github.com/getsentry/onpremise/blob/c16ae024dc3e8259b03679f950e80e1cbfb5dae8/install/check-minimum-requirements.sh#L11

Instead of this one:

https://github.com/getsentry/onpremise/blob/c16ae024dc3e8259b03679f950e80e1cbfb5dae8/install/check-minimum-requirements.sh#L8

Can you confirm these hypotheses, please? :)

If my hypotheses are correct, then the question is, why are you failing the check on line 7?

https://github.com/getsentry/onpremise/blob/c16ae024dc3e8259b03679f950e80e1cbfb5dae8/install/check-minimum-requirements.sh#L7

We already have the output of docker version and docker-compose --version ... what is the output of docker compose version?

@mowangjuanzi
Copy link
Author

yes. i think the execute result is the value is v2.0.1。but the right result is 2.0.1 。the reson is the output value of docker compose version has changed.

PS C:\Users\baogu\Downloads> docker-compose --version
Docker Compose version v2.0.0
PS C:\Users\baogu\Downloads> .\docker-compose-Windows-x86_64.exe --version
docker-compose version 1.29.2, build 5becea4c

@chadwhitacre
Copy link
Member

chadwhitacre commented Nov 4, 2021

What's the output of docker compose version (not docker-compose --version ;)?

@mowangjuanzi
Copy link
Author

PS C:\Users\baogu> docker compose version
Docker Compose version v2.0.0

I cannot execute docker compose version correctly in ubuntu.

@chadwhitacre
Copy link
Member

I cannot execute docker compose version correctly in ubuntu.

Why not? That's presumably the reason you're failing the check on line 7.

@mowangjuanzi
Copy link
Author

$ docker-compose version
Docker Compose version v2.0.1
$ docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'

operate system is ubuntu 21.10.

$ docker version
Client: Docker Engine - Community
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:43:58 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:42:04 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

@mowangjuanzi
Copy link
Author

It's too late. I'm going to bed。 good night.

@chadwhitacre
Copy link
Member

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

Curious. How did you end up with a v2 docker-compose without docker compose? What was your installation method? 🤔

I'm going to go ahead and close this. It looks like you need to either downgrade docker-compose to v1, or upgrade docker so that you have docker compose available. If there's something weird going on with the packaged version of docker that you're installing, feel free to note here for future reference, but I'm not sure we'll want to try very hard to work around packaging foibles.

@chadwhitacre
Copy link
Member

From #1166 (comment):

Rocky Linux release 8.4 (Green Obsidian)

@chadwhitacre
Copy link
Member

chadwhitacre commented Nov 23, 2021

Reopening, as @jsanagustin reports at #1166 (comment) that this is likely related to CentOS packaging:

In the last post you made on that issue, you seem to indicate that docker compose comes packaged with docker engine, which is not the case. At least, not when installing docker via docker's CentOS repository as detailed here. After installing docker from their repo, I followed their instructions to install compose, as detailed here, substituting v2.0.1 instead of 1.29.2.

#1132 (comment)

I'm not sure we'll want to try very hard to work around packaging foibles.

Yeah okay now I'm waffling. :)

@chadwhitacre chadwhitacre reopened this Nov 23, 2021
@chadwhitacre chadwhitacre changed the title Docker Compose Version Check Error Make Docker Compose version check more forgiving Nov 23, 2021
@chadwhitacre chadwhitacre pinned this issue Nov 23, 2021
@chadwhitacre chadwhitacre unpinned this issue Nov 29, 2021
@chadwhitacre
Copy link
Member

I'm doing a little test of old docker versions.

/Users/chadwhitacre/Desktop/dc
total 128
-rwxr-xr-x  1 chadwhitacre  staff     9 Nov 30 11:47 docker-compose-1.0.0*
-rwxr-xr-x  1 chadwhitacre  staff     9 Nov 30 11:47 docker-compose-1.1.0*
-rwxr-xr-x  1 chadwhitacre  staff  1413 Nov 30 11:47 docker-compose-1.10.0*
-rwxr-xr-x  1 chadwhitacre  staff  1413 Nov 30 11:47 docker-compose-1.11.0*
-rwxr-xr-x  1 chadwhitacre  staff  1411 Nov 30 11:47 docker-compose-1.12.0*
-rwxr-xr-x  1 chadwhitacre  staff  1411 Nov 30 11:47 docker-compose-1.13.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.14.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.15.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.16.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.17.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.18.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.19.0*
-rwxr-xr-x  1 chadwhitacre  staff     9 Nov 30 11:47 docker-compose-1.2.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.20.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.21.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.22.0*
-rwxr-xr-x  1 chadwhitacre  staff  1666 Nov 30 11:47 docker-compose-1.23.0*
-rwxr-xr-x  1 chadwhitacre  staff  1702 Nov 30 11:47 docker-compose-1.24.0*
-rwxr-xr-x  1 chadwhitacre  staff  1698 Nov 30 11:47 docker-compose-1.25.0*
-rwxr-xr-x  1 chadwhitacre  staff  1789 Nov 30 11:47 docker-compose-1.26.0*
-rwxr-xr-x  1 chadwhitacre  staff  2053 Nov 30 11:47 docker-compose-1.27.0*
-rwxr-xr-x  1 chadwhitacre  staff  2585 Nov 30 11:47 docker-compose-1.28.0*
-rwxr-xr-x  1 chadwhitacre  staff  2585 Nov 30 11:47 docker-compose-1.29.0*
-rwxr-xr-x  1 chadwhitacre  staff     9 Nov 30 11:47 docker-compose-1.3.0*
-rwxr-xr-x  1 chadwhitacre  staff     9 Nov 30 11:47 docker-compose-1.4.0*
-rwxr-xr-x  1 chadwhitacre  staff  1087 Nov 30 11:47 docker-compose-1.5.0*
-rwxr-xr-x  1 chadwhitacre  staff  1325 Nov 30 11:47 docker-compose-1.6.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.7.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.8.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.9.0*
-rwxr-xr-x  1 chadwhitacre  staff   146 Nov 30 11:47 download-docker-composes*
-rwxr-xr-x  1 chadwhitacre  staff    90 Nov 30 11:48 versions*
$ cat docker-compose-1.0.0 
Not Found%                                                                                                                         $
#!/usr/bin/env zsh
for i in {0..29}; do
  curl -L https://github.com/docker/compose/releases/download/1.$i.0/run.sh -o docker-compose-1.$i.0
done
#!/usr/bin/env zsh
for i in {1..29}; do
  ./docker-compose-1.$i.0 version | head -n1
done

@chadwhitacre
Copy link
Member

Second run of versions (first filled with build spam):

$ ./versions 
./docker-compose-1.1.0: line 1: Not: command not found
./docker-compose-1.2.0: line 1: Not: command not found
./docker-compose-1.3.0: line 1: Not: command not found
./docker-compose-1.4.0: line 1: Not: command not found
docker-compose version: 1.5.0
docker-compose version 1.6.0, build d99cad6
docker-compose version 1.7.0, build 0d7bf73
docker-compose version 1.8.0, build f3628c7
docker-compose version 1.9.0, build 2585387
docker-compose version 1.10.0, build 4bd6f1a
docker-compose version 1.11.0, build 6de1806
docker-compose version 1.12.0, build b31ff33
docker-compose version 1.13.0, build 1719ceb
docker-compose version 1.14.0, build c7bdf9e
docker-compose version 1.15.0, build e12f3b9
docker-compose version 1.16.0, build ea60ca1
docker-compose version 1.17.0, build ac53b73
docker-compose version 1.18.0, build 8dd22a9
docker-compose version 1.19.0, build 9e633ef
docker-compose version 1.20.0, build f86cf45
docker-compose version 1.21.0, build 5920eb0
docker-compose version 1.22.0, build f46880fe
docker-compose version 1.23.0, build c8524dc1
docker-compose version 1.24.0, build 0aa59064
docker-compose version 1.25.0, build b42d419
docker-compose version 1.26.0, build d445165
docker-compose version 1.27.0, build 980ec85
docker-compose version 1.28.0, build d02a7b1
docker-compose version 1.29.0, build 0773730
$

@chadwhitacre
Copy link
Member

chadwhitacre commented Nov 30, 2021

I removed the "Not found" versions.

/Users/chadwhitacre/Desktop/dc
total 116
-rwxr-xr-x  1 chadwhitacre  staff  1413 Nov 30 11:47 docker-compose-1.10.0*
-rwxr-xr-x  1 chadwhitacre  staff  1413 Nov 30 11:47 docker-compose-1.11.0*
-rwxr-xr-x  1 chadwhitacre  staff  1411 Nov 30 11:47 docker-compose-1.12.0*
-rwxr-xr-x  1 chadwhitacre  staff  1411 Nov 30 11:47 docker-compose-1.13.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.14.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.15.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.16.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.17.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.18.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.19.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.20.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.21.0*
-rwxr-xr-x  1 chadwhitacre  staff  1480 Nov 30 11:47 docker-compose-1.22.0*
-rwxr-xr-x  1 chadwhitacre  staff  1666 Nov 30 11:47 docker-compose-1.23.0*
-rwxr-xr-x  1 chadwhitacre  staff  1702 Nov 30 11:47 docker-compose-1.24.0*
-rwxr-xr-x  1 chadwhitacre  staff  1698 Nov 30 11:47 docker-compose-1.25.0*
-rwxr-xr-x  1 chadwhitacre  staff  1789 Nov 30 11:47 docker-compose-1.26.0*
-rwxr-xr-x  1 chadwhitacre  staff  2053 Nov 30 11:47 docker-compose-1.27.0*
-rwxr-xr-x  1 chadwhitacre  staff  2585 Nov 30 11:47 docker-compose-1.28.0*
-rwxr-xr-x  1 chadwhitacre  staff  2585 Nov 30 11:47 docker-compose-1.29.0*
-rwxr-xr-x  1 chadwhitacre  staff  1087 Nov 30 11:47 docker-compose-1.5.0*
-rwxr-xr-x  1 chadwhitacre  staff  1325 Nov 30 11:47 docker-compose-1.6.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.7.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.8.0*
-rwxr-xr-x  1 chadwhitacre  staff  1400 Nov 30 11:47 docker-compose-1.9.0*
-rwxr-xr-x  1 chadwhitacre  staff    37 Nov 30 12:07 docker-compose-2*
-rwxr-xr-x  1 chadwhitacre  staff   146 Nov 30 11:47 download-docker-composes*
-rwxr-xr-x  1 chadwhitacre  staff   159 Nov 30 12:33 parse-version*
$

@chadwhitacre
Copy link
Member

Here's a parse pipe that seems to work:

#!/usr/bin/env zsh

rm versions
for dc in docker-compose-$1*; do
  ./$dc version | head -n1 | sed 's/^.* version:\{0,1\} v\{0,1\}\([0-9.]\{1,\}\).*$/\1/'
done

Oh ... I also stubbed out a docker-compose-2 for testing:

#!/usr/bin/env zsh
docker compose $@

Results:

$ ./parse-version
1.10.0
1.11.0
1.12.0
1.13.0
1.14.0
1.15.0
1.16.0
1.17.0
1.18.0
1.19.0
1.20.0
1.21.0
1.22.0
1.23.0
1.24.0
1.25.0
1.26.0
1.27.0
1.28.0
1.29.0
1.5.0
     1.6.0
1.7.0
1.8.0
1.9.0
2.0.0
$

I wrestled for a while with 1.5.0 ... I'm pretty sure there's a carriage return at the end that is boogering it up, I tried matching that in the sed regex but gave up, 1.5 is ancient, and this'll fail the version check anyway probably right? ¯\_(ツ)_/¯

@chadwhitacre
Copy link
Member

cc: @thenets ... additional context for #1177 / #1179.

@chadwhitacre
Copy link
Member

Done in #1179.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants