Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

services.<container>.restart must be a string on docker-compose V2 #1971

Closed
GeoJunkie opened this issue Jul 30, 2021 · 3 comments
Closed

services.<container>.restart must be a string on docker-compose V2 #1971

GeoJunkie opened this issue Jul 30, 2021 · 3 comments
Labels
discussion 💬 Discussing usage, best practices, questions, etc.

Comments

@GeoJunkie
Copy link

Description
We have the following restart option in a service:

  db:
....
    restart: ${RESTART_DB-always}

It works with docker-compose up V1, but in V2 it receives an error: services.db.restart must be a string

Steps to reproduce the issue:

  1. Create a service using an expansion for the restart
  2. Run docker compose up
  3. See the error

Describe the results you received:

services.db.restart must be a string

Describe the results you expected:

The option should continue to work in docker-compose v2.

Additional information you deem important (e.g. issue happens only occasionally):

**Output of docker-compose --version: ***

docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020

Output of docker version:

Client:
 Cloud integration: 1.0.17
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.16.4
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:22 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:54:58 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.


    {
        "Name": "default",
        "Metadata": {
            "StackOrchestrator": "swarm"
        },
        "Endpoints": {
            "docker": {
                "Host": "unix:///var/run/docker.sock",
                "SkipTLSVerify": false
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "\u003cIN MEMORY\u003e",
            "TLSPath": "\u003cIN MEMORY\u003e"
        }
    }
]

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-beta.6)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 20
  Running: 0
  Paused: 0
  Stopped: 20
 Images: 24
 Server Version: 20.10.7
 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: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 1.94GiB
 Name: docker-desktop
 ID: MYPK:YAXQ:AFCT:YTZF:4SOK:5UMH:NQH5:MZWB:4UBO:P7MS:OD5I:CCIS
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS ECS, Azure ACI, local, etc.):

@ndeloof
Copy link
Collaborator

ndeloof commented Aug 2, 2021

compose-go library we rely on to parse the compose.yaml file relies on goyaml.v2 which unfortunately applied yaml 1.1 schema to assume "true" string MUST be parsed as a boolean.
A possible workaround is to wrap value with quotes:

  db:
....
    restart: "${RESTART_DB-always}"

@ndeloof ndeloof added the discussion 💬 Discussing usage, best practices, questions, etc. label Aug 2, 2021
@ndeloof
Copy link
Collaborator

ndeloof commented Aug 2, 2021

see compose-spec/compose-go#139

@ndeloof
Copy link
Collaborator

ndeloof commented Aug 5, 2021

fixed by compose-spec/compose-go#162

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion 💬 Discussing usage, best practices, questions, etc.
Projects
None yet
Development

No branches or pull requests

2 participants