Unable to add volume to image via docker-compose

2017-12-07T12:58:06

I'm trying to add a volume to the mattermost/mattermost-preview docker image. The Dockerfile for this image (not controlled by me) is:

# Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
# See License.txt for license information.
FROM mysql:5.7

# Install ca-certificates to support TLS of Mattermost v3.5
RUN apt-get update && apt-get install -y ca-certificates

#
# Configure SQL
#

ENV MYSQL_ROOT_PASSWORD=mostest
ENV MYSQL_USER=mmuser
ENV MYSQL_PASSWORD=mostest
ENV MYSQL_DATABASE=mattermost_test

#
# Configure Mattermost
#
WORKDIR /mm

# Copy over files
ADD https://releases.mattermost.com/4.4.4/mattermost-team-4.4.4-linux-amd64.tar.gz .
RUN tar -zxvf ./mattermost-team-4.4.4-linux-amd64.tar.gz
ADD config_docker.json ./mattermost/config/config_docker.json
ADD docker-entry.sh .

RUN chmod +x ./docker-entry.sh
ENTRYPOINT ./docker-entry.sh

# Create default storage directory
RUN mkdir ./mattermost-data
VOLUME ./mattermost-data

# Ports
EXPOSE 8065

I want to add a volume to this image, and a custom entrypoint so that I can add some test data to the mysql database before my container starts up. I'm trying to use docker-compose to do this:

version: '3'
services:
  mattermost:
    ports:
     - "8065:8065"
    image: mattermost/mattermost-preview
    volumes:
      - ./end_to_end/mattermost/mock-mount:/mm/mock-mount
    entrypoint: /mm/mock-mount/docker-entry.sh

But I'm unfortunately not able to get this to start, when I try running docker-compose up, I get the error

ERROR: for mattermost  Cannot create container for service mattermost: invalid bind mount spec "39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw": invalid volume specification: '39742853c03b3b2747f11c942a4a76e4cd138ad41d54f70f71d7aa9ccc36dcca:mattermost-data:rw': invalid mount config for type "volume": invalid mount path: 'mattermost-data' mount path must be absolute
ERROR: Encountered errors while bringing up the project.

The weird thing is - if I take out the volumes and entrypoint sections from my docker-compose.yml file, then the container starts up no problem, even though it seems to me that the error is with the original image. Is there a way to do what I want here?

Copyright License:
Author:「Lily Mara」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/47687893/unable-to-add-volume-to-image-via-docker-compose

About “Unable to add volume to image via docker-compose” questions

I'm trying to add a volume to the mattermost/mattermost-preview docker image. The Dockerfile for this image (not controlled by me) is: # Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. # ...
If I have a docker-compose file like: version: "3" services: postgres: image: postgres:9.4 volumes: - db-data:/var/lib/db volumes: db-data: ... then doing docker-compos...
I have a docker image of Grafana 8.0.5. I created a volume using docker volume create grafana-storage I can stop the volume, and bring it back up with no data loss. However, if I update my docker-c...
I've been playing with Docker for the past week and think the container idea is very useful, but despite reading everything I can for the past 3 days I can't get the volume mapping to work get doc...
I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a default folder. Tha...
I have for example this service and volume defined in my docker-compose file postgres: image: postgres:9.4 volumes: - db_data:/var/lib/postgresql/data volumes: blue_prod_db: ...
I am using docker-compose to spin up a spring api with a postgres database . I am new to docker and I am trying to persist my database using a named volume I created with docker volume create
Hi I have written a docker-compose file and It is working but I am not able to located it volume location. I wanted to write proper docker-compose file for a persistent volume and have a MongoDB on...
I'm trying to replicate docker run command with options within a docker-compose file: My Dockerfile is: FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y RUN apt-get ins...
I have a pretty simple docker-compose setup which is working on my colleague computer (*), but for some obscure reason it doesn't work on mine. Here is my docker-compose.yml version: '3.3' servic...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.