Compose: Previous container volumes warnings even with `--force-recreate`

Created on 1 Dec 2015  路  11Comments  路  Source: docker/compose

When calling docker-compose up --force-recreate, I see warnings about volumes from previous containers being used, even though, as I understand it (per conversion w/ @dnephin on #docker-compose), this should be a non-issue.

WARNING: Service "frontend" is using volume "/.foo" from the previous container. Host mapping "/home/user/.foo" has no effect. Remove the existing containers (with `docker-compose rm frontend`) to use the host volume mapping.

Most helpful comment

@alanfranz nevermind, it was user error. The error message in my case was alerting me to the fact that the container being replaced was still using an un-named volume, and the change I made to my compose YAML to use a named volume won't take effect. I just needed to "down" the old container on the switch-over.

All 11 comments

This is a regression in 1.5.1, which is fixed for 1.5.2 (to be released soon).

You can grab a version of master: https://dl.bintray.com/docker-compose/master/ if you'd like to try it out before the 1.5.2 release.

Related issue: #2390

I have this same issue on docker-compose version 1.5.2

WARNING: Service "data" is using volume "/var/lib/postgresql" from the previous container. Host mapping "None" has no effect. Remove the existing containers (with `docker-compose rm data`) to use the host volume mapping.
docker-compose version 1.5.2, build unknown

The warning is still there, it should only be printed when a volume is actually being masked.

Could you include your docker-compose.yml and the output of a docker inspect for the container?

I just upgraded and see the same thing:

docker-compose version 1.5.2, build 7240ff3

$ docker-compose -f myapp-staging.yml up -d --force-recreate web
Recreating myapp_data_1
WARNING: Service "data" is using volume "/var/lib/postgresql" from the previous container. Host mapping "None" has no effect. Remove the existing containers (with `docker-compose rm data`) to use the host volume mapping.
Recreating myapp_postgres_1
Recreating myapp_web_1
WARNING: Service "web" is using volume "/usr/src/app/myapp/ui/dist/static" from the previous container. Host mapping "None" has no effect. Remove the existing containers (with `docker-compose rm web`) to use the host volume mapping.
WARNING: Service "web" is using volume "/usr/src/app/landingpage" from the previous container. Host mapping "None" has no effect. Remove the existing containers (with `docker-compose rm web`) to use the host volume mapping.

docker-compose.yml:

web:
  restart: 'always'
  build: ./web
  expose:
    - '8000'
  links:
    - postgres:postgres
  volumes:
    - /usr/src/app/myapp/ui/dist/static
    - /usr/src/app/landingpage
  env_file: .env-staging
  command: /usr/local/bin/gunicorn -w 2 -b :8000 myapp.main:app

nginx:
  restart: 'always'
  build: ./nginx
  ports:
    - '80:80'
  volumes_from:
    - web
  links:
    - web:web

data:
  image: postgres:9.4.5
  restart: 'no'
  volumes:
    - /var/lib/postgresql
  command: 'true'

postgres:
  image: postgres:9.4.5
  restart: 'always'
  env_file: .env-staging
  ports:
    - '5432:5432'
  volumes_from:
    - data

and docker inspect

$ docker inspect myapp_web
[
{
    "Id": "048b25633e887131922f477f2bbf37127970844e9fb0c531046d8e9566343248",
    "RepoTags": [
        "myapp_web:latest"
    ],
    "RepoDigests": [],
    "Parent": "3b7740d76719a22c94d35389609c596fdfbcd17d7f6df519dea7b27e03980a9b",
    "Comment": "",
    "Created": "2016-01-05T01:26:34.043350785Z",
    "Container": "a3b1cffa49908c1a036c7250d7fbc55cbf7d0a8ec2b94e63e8701a862addc37d",
    "ContainerConfig": {
        "Hostname": "609b1a101af3",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "LANG=C.UTF-8",
            "PYTHON_VERSION=3.4.4",
            "PYTHON_PIP_VERSION=7.1.2",
            "NODE_VERSION=5.3.0"
        ],
        "Cmd": [
            "/bin/sh",
            "-c",
            "cd myapp/ui \u0026\u0026 ./node_modules/.bin/gulp dist \u0026\u0026 mkdir -p /usr/local/myapp/uploads"
        ],
        "Image": "3b7740d76719a22c94d35389609c596fdfbcd17d7f6df519dea7b27e03980a9b",
        "Volumes": null,
        "WorkingDir": "/usr/src/app",
        "Entrypoint": null,
        "OnBuild": [],
        "Labels": {}
    },
    "DockerVersion": "1.9.1",
    "Author": "",
    "Config": {
        "Hostname": "609b1a101af3",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "LANG=C.UTF-8",
            "PYTHON_VERSION=3.4.4",
            "PYTHON_PIP_VERSION=7.1.2",
            "NODE_VERSION=5.3.0"
        ],
        "Cmd": [
            "python3"
        ],
        "Image": "3b7740d76719a22c94d35389609c596fdfbcd17d7f6df519dea7b27e03980a9b",
        "Volumes": null,
        "WorkingDir": "/usr/src/app",
        "Entrypoint": null,
        "OnBuild": [],
        "Labels": {}
    },
    "Architecture": "amd64",
    "Os": "linux",
    "Size": 847653,
    "VirtualSize": 906856274,
    "GraphDriver": {
        "Name": "aufs",
        "Data": null
    }
}
]

apologies, the above inspect output seems to be lacking info...here are more full details:

$ docker inspect f62529829ead
[
{
    "Id": "f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167",
    "Created": "2016-01-05T02:01:22.220635282Z",
    "Path": "/usr/local/bin/gunicorn",
    "Args": [
        "-w",
        "2",
        "-b",
        ":8000",
        "myapp.main:app"
    ],
    "State": {
        "Status": "running",
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 656,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2016-01-05T02:01:22.503586276Z",
        "FinishedAt": "0001-01-01T00:00:00Z"
    },
    "Image": "048b25633e887131922f477f2bbf37127970844e9fb0c531046d8e9566343248",
    "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167/resolv.conf",
    "HostnamePath": "/mnt/sda1/var/lib/docker/containers/f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167/hostname",
    "HostsPath": "/mnt/sda1/var/lib/docker/containers/f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167/hosts",
    "LogPath": "/mnt/sda1/var/lib/docker/containers/f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167/f62529829ead9b1c6cfffc94bff923048a558ed275bc7416c08807f91d467167-json.log",
    "Name": "/myapp_web_1",
    "RestartCount": 0,
    "Driver": "aufs",
    "ExecDriver": "native-0.2",
    "MountLabel": "",
    "ProcessLabel": "",
    "AppArmorProfile": "",
    "ExecIDs": null,
    "HostConfig": {
        "Binds": [
            "/mnt/sda1/var/lib/docker/volumes/2f3669a4008b9121756ef688c56ab33de273752f92887e053a19321bc06c7758/_data:/usr/src/app/landingpage:rw",
            "/mnt/sda1/var/lib/docker/volumes/b1e248b3925aee601942520f72e2b60c8c98823a521e4573fd45cfd6bc58ef6a/_data:/usr/src/app/myapp/ui/dist/static:rw"
        ],
        "ContainerIDFile": "",
        "LxcConf": null,
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "KernelMemory": 0,
        "CpuShares": 0,
        "CpuPeriod": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "CpuQuota": 0,
        "BlkioWeight": 0,
        "OomKillDisable": false,
        "MemorySwappiness": null,
        "Privileged": false,
        "PortBindings": {},
        "Links": [
            "/myapp_postgres_1:/myapp_web_1/myapp_postgres_1",
            "/myapp_postgres_1:/myapp_web_1/postgres",
            "/myapp_postgres_1:/myapp_web_1/postgres_1"
        ],
        "PublishAllPorts": false,
        "Dns": null,
        "DnsOptions": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "VolumesFrom": [],
        "Devices": null,
        "NetworkMode": "default",
        "IpcMode": "",
        "PidMode": "",
        "UTSMode": "",
        "CapAdd": null,
        "CapDrop": null,
        "GroupAdd": null,
        "RestartPolicy": {
            "Name": "always",
            "MaximumRetryCount": 0
        },
        "SecurityOpt": null,
        "ReadonlyRootfs": false,
        "Ulimits": null,
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "CgroupParent": "",
        "ConsoleSize": [
            0,
            0
        ],
        "VolumeDriver": ""
    },
    "GraphDriver": {
        "Name": "aufs",
        "Data": null
    },
    "Mounts": [
        {
            "Source": "/mnt/sda1/var/lib/docker/volumes/2f3669a4008b9121756ef688c56ab33de273752f92887e053a19321bc06c7758/_data",
            "Destination": "/usr/src/app/landingpage",
            "Mode": "rw",
            "RW": true
        },
        {
            "Source": "/mnt/sda1/var/lib/docker/volumes/b1e248b3925aee601942520f72e2b60c8c98823a521e4573fd45cfd6bc58ef6a/_data",
            "Destination": "/usr/src/app/myapp/ui/dist/static",
            "Mode": "rw",
            "RW": true
        }
    ],
    "Config": {
        "Hostname": "f62529829ead",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "ExposedPorts": {
            "8000/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "JSON_AS_ASCII=FALSE",
            "SQLALCHEMY_TRACK_MODIFICATIONS=FALSE",
            "SECURITY_PASSWORD_SCHEME=pbkdf2_sha512",
            "MIGRATION_DIR=myapp/migrations",
            "DB_PORT=5432",
            "DB_PASS=postgres",
            "DB_NAME=postgres",
            "SQLALCHEMY_LOG_LEVEL=DEBUG",
            "DEBUG=TRUE",
            "SECRET_KEY=secretkey",
            "REDISTOGO_URL=redis://localhost:6379",
            "CSRF_ENABLED=TRUE",
            "DEVELOPMENT=TRUE",
            "affinity:container==49e77d14fa8d3d3b124d3cea178232542f3bec2b27e1d87bb02323994f31832d",
            "JSON_USE_ENCODE_METHODS=TRUE",
            "JWT_ISSUER=myapp.com",
            "TEMPLATES_FOLDER=myapp/ui/dist/templates",
            "TESTING=FALSE",
            "JSON_DATETIME_FORMAT=%Y-%m-%dT%H:%M:%SZ",
            "STATIC_FOLDER=ui/dist/static",
            "DB_USER=postgres",
            "JWT_AUTH_URL_RULE=",
            "DB_SERVICE=postgres",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "LANG=C.UTF-8",
            "PYTHON_VERSION=3.4.4",
            "PYTHON_PIP_VERSION=7.1.2",
            "NODE_VERSION=5.3.0"
        ],
        "Cmd": [
            "/usr/local/bin/gunicorn",
            "-w",
            "2",
            "-b",
            ":8000",
            "myapp.main:app"
        ],
        "Image": "myapp_web",
        "Volumes": {
            "/usr/src/app/landingpage": {},
            "/usr/src/app/myapp/ui/dist/static": {}
        },
        "WorkingDir": "/usr/src/app",
        "Entrypoint": null,
        "OnBuild": null,
        "Labels": {
            "com.docker.compose.config-hash": "ae9ec676be39e86bcd9948cd121190b48b3db72f6652fdf9ee66e8e9af20f5a2",
            "com.docker.compose.container-number": "1",
            "com.docker.compose.oneoff": "False",
            "com.docker.compose.project": "myapp",
            "com.docker.compose.service": "web",
            "com.docker.compose.version": "1.5.2"
        }
    },
    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "fae3605145614492e66ae3b053c968b8832a6eadbc2166c7feb498341a7fbb0c",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "8000/tcp": null
        },
        "SandboxKey": "/var/run/docker/netns/fae360514561",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "77fedf9c05499cd85e05fc74cce9f098b6ea4c3c7865ec51e5baeb15efa50564",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "172.17.0.4",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "MacAddress": "02:42:ac:11:00:04",
        "Networks": {
            "bridge": {
                "EndpointID": "77fedf9c05499cd85e05fc74cce9f098b6ea4c3c7865ec51e5baeb15efa50564",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.4",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:04"
            }
        }
    }
}
]

Thanks for the report and the compose file example. I was able to reproduce the issue and opened #2609 to fix it. The fix will be in the next release.

Hello @dnephin , I still encounter this issue with docker-compose 1.8.1 and docker-engine 1.12.1 (docker.io package straight from Ubuntu repos):

Service "cassandra" is using volume "/var/lib/cassandra" from the previous container. Host mapping "/home/ubuntu/data/docker/cassandra" has no effect. Remove the existing containers (with docker-compose rm cassandra) to use the host volume mapping.

What I do:

  • In my continuous delivery pipeline, the docker-compose.yml file is updated on a remote machine, then a "docker-compose pull && docker-compose up --force-recreate -d" is performed on such machine; I never do a "docker-compose down", mind you.
  • I had a docker-compose.yml file where there was no volume mapping defined
  • Then, I added a volume mapping in such file;
  • Now I get that error when the 'up' command is performed.

Two questions:

  • Is that expected?
  • What is the "right way" to perform an update of my cluster with minimal downtime? I would have expected that an "up", even without "--force-recreate", would restart the container from the image, since it's configuration had changed;

@alanfranz , did you ever get an answer to your most recent question? I am having the same issue with docker-engine 1.13.0 and docker-compose 1.10.1.

@alanfranz nevermind, it was user error. The error message in my case was alerting me to the fact that the container being replaced was still using an un-named volume, and the change I made to my compose YAML to use a named volume won't take effect. I just needed to "down" the old container on the switch-over.

down/up fixed the same issue... thanks for the 3 year old advice.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darkrasid picture darkrasid  路  3Comments

CrimsonGlory picture CrimsonGlory  路  3Comments

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  路  3Comments

saulshanabrook picture saulshanabrook  路  3Comments

Hendrik-H picture Hendrik-H  路  3Comments