Compose: workdir option on exec command is causing an error

Created on 20 Feb 2019  路  4Comments  路  Source: docker/compose

Description of the issue

When running docker-compose -w /root test sh I get the error: ERROR: Setting workdir for exec is not supported in API < 1.35 (1.25) even though I think my client API is over 1.35.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.23.2, build unknown
docker-py version: 3.7.0
CPython version: 3.7.2
OpenSSL version: OpenSSL 1.1.1a  20 Nov 2018

Output of docker version

Client:
 Version:           18.09.1-ce
 API version:       1.39
 Go version:        go1.11.5
 Git commit:        4c52b901c6
 Built:             Sun Feb 10 18:14:18 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.1-ce
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.11.5
  Git commit:       4c52b901c6
  Built:            Sun Feb 10 18:11:52 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker-compose config

services:
  test:
    command: watch date
    image: alpine
version: '3.0'

Steps to reproduce the issue

  1. docker-compose up -d
  2. docker-compose exec -w /root test sh

Observed result

ERROR: Setting workdir for exec is not supported in API < 1.35 (1.25)

Expected result

sh should start shell in /root directory because of the working directory change option.

Additional information

Tested on Arch Linux downloaded through pacman official package manager.

Most helpful comment

Y'all need to add a declaration in your docker-compose.yml for:

version: '3.6'

... or later (3.7). If you are seeing API version 1.25 reported, you are running a 3.0-3.2 version or thereabouts.

All 4 comments

I also get this error on Docker Desktop for Mac Edge with versions:

docker-compose version 1.24.0-rc1, build 0f3d4dda
docker-py version: 3.7.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018

and

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     true

Updated to latest versions of both docker and docker-compose and still no luck:

Docker

Client:
 Version:           18.09.3
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        774a1f4
 Built:             Thu Feb 28 06:47:20 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.3
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       774a1f4
  Built:            Thu Feb 28 05:59:55 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Docker Compose

docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.7
OpenSSL version: OpenSSL 1.1.0f  25 May 2017

Y'all need to add a declaration in your docker-compose.yml for:

version: '3.6'

... or later (3.7). If you are seeing API version 1.25 reported, you are running a 3.0-3.2 version or thereabouts.

As far as I'm concerned this issue is resolved.

Perhaps it could be more clear that some of the docker-compose options do not work with some compose versions.

Was this page helpful?
0 / 5 - 0 ratings