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

[BUG] docker compose up still have errors strconv.Atoi: parsing "": invalid syntax #10162

Closed
yckaolalala opened this issue Jan 11, 2023 · 5 comments · Fixed by #10177
Closed
Assignees
Labels

Comments

@yckaolalala
Copy link

yckaolalala commented Jan 11, 2023

Description

in v2.15.1 docker compose up still have errors strconv.Atoi: parsing "": invalid syntax
if build with docker-compose v1 or using docker build can fix it

Related issues:
#10004

Steps To Reproduce

configuration

  • docker-compose.yaml
version: '3'
services:
  test:
    image: test:latest
    build:
      context: ./
  • Dockerfile
FROM golang:1.19-alpine

step

  • build image
docker-compose build
  • run using docker command and not remove
docker run test:latest ls
docker ps -a
CONTAINER ID   IMAGE         COMMAND                  CREATED         STATUS                     PORTS                            NAMES
de79add1d7a8   test:latest   "ls"                     7 seconds ago   Exited (0) 7 seconds ago                                    awesome_visvesvaraya
  • using docker-compose up and error
docker-compose up
WARN[0000] container de79add1d7a809dd899d380db5249f3077585c9e43252841a7054cf8711494c9 is missing com.docker.compose.container-number label 
WARN[0000] container de79add1d7a809dd899d380db5249f3077585c9e43252841a7054cf8711494c9 has invalid com.docker.compose.container-number label:  
[+] Running 1/0
 ⠿ Network issue-10004_default    Created                                  0.1s
 ⠋ Container romantic_archimedes  Recre...                                 0.0s
strconv.Atoi: parsing "": invalid syntax

Compose Version

Docker Compose version v2.15.1

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.14.1)
  scan: Docker Scan (Docker Inc., v0.23.0)

Server:
 Containers: 2
  Running: 1
  Paused: 0
  Stopped: 1
 Images: 440
 Server Version: 20.10.22
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-135-generic
 Operating System: Ubuntu 18.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 23.33GiB
 Name: DESKTOP
 ID: WFYM:JHFJ:WXVJ:EXYY:SBOY:Y5MC:7NXY:5BNN:6F2Y:PGIO:UZYV:EBHQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@laurazard
Copy link
Member

Hi @yckaolalala, thanks for the report. Could you provide the output of docker inspect [your container name/id] so I can look into this a little more?

@ndeloof
Copy link
Contributor

ndeloof commented Jan 11, 2023

I was able to reproduce with reported scenario

The root cause is that the image we build are labelled with com.docker.compose.project and com.docker.compose.service (IIRC this is used to help track image we built for project). Doing so container created by docker run ... also has such labels, and compose get confused because it miss a container-number label.

@ghpu
Copy link

ghpu commented Jan 16, 2023

As a work-around, I add a label during my builds :

prefect-server:
    image: prefect
    build:
      dockerfile: docker/prefect
      labels:
        # workaround around a docker-compose bug when image is also used by docker run (https://github.com/docker/compose/issues/10162)
        com.docker.compose.container-number: "1"

@laurazard
Copy link
Member

Ahhh I see the issue. @ndeloof do we want to do anything about this? I don't see any obvious changes to make, asides from introducing a new label when creating containers from compose create/compose up to specify that the container was created by us and not docker run.

@ndeloof
Copy link
Contributor

ndeloof commented Jan 17, 2023

We can distinguish containers ran by compose by the com.docker.compose.config-hash label. Our getContainers function could filter by this label, to ensure we ignore other containers created by user from image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants