1

I'm running a Docker deployment for an application. I'm mounting a volume where I want the external path to be provided by a shell environment variable. I get this error:

ERROR: for video-server Cannot create container for service video-server: invalid volume specification: '46b9d2fb3b9b13c9404d31bae571dac3f633122393c4a77f2561afb8aed5c06e:=/opt/videos:rw': invalid mount config for type "volume": invalid mount path: '=/opt/videos' mount path must be absolute

My docker-compose configuration is this:

video-server:
    build:
      context: .
      dockerfile: video-server_Dockerfile
    container_name: video-server
    networks:
      - videoManagerNetwork
    environment:
      - VIDEO_MANAGER_DIR=/opt/videos
    volumes:
      - ${VIDEO_MANAGER_DIR_PROD}=/opt/videos
    ports:
      - 9000:8080

I can see the correct value of the VIDEO_MANAGER_DIR_PROD environment variable by doing both of these commands, so I know it's on my shell:

echo $VIDEO_MANAGER_DIR_PROD
sudo echo $VIDEO_MANAGER_DIR_PROD

What's strange is that, if I do a complete wipe of my docker configurations (sudo docker system prune --all --volumes), and then run the docker-compose for the first time (sudo docker-compose up -d), everything works.

However, if I take the container down, rebuild it, and try to run that same command (sudo docker-compose up -d) again, then I get the error displayed above.

1
  • Is the host path an absolute path (does it start with /)? There should be a : after it, not an =, in the volumes: specification. Commented Mar 27, 2019 at 22:31

1 Answer 1

1

You cannot assign the source volume like a variable, so you will use : for this assignment.

Documentation about Docker Compose volumes: docs.docker.com

video-server:
  build:
    context: .
    dockerfile: video-server_Dockerfile
  container_name: video-server
    networks:
      - videoManagerNetwork
    environment:
      - VIDEO_MANAGER_DIR: /opt/videos
    volumes:
      - ${VIDEO_MANAGER_DIR_PROD}:/opt/videos
    ports:
      - 9000:8080
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.