无法通过docker-compose向图像添加体积 [英] Unable to add volume to image via docker-compose

查看:83
本文介绍了无法通过docker-compose向图像添加体积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将卷添加到 mattermost / mattermost-preview 泊坞窗图片。此映像的Dockerfile(不受我控制)是:

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

我想向该图像添加一个卷,并添加一个自定义入口点,以便在容器启动之前可以向mysql数据库添加一些测试数据。我正在尝试使用docker-compose做到这一点:

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

但是不幸的是,我无法启动它,当我尝试运行 docker-compose up 时,出现错误

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.

奇怪的是-如果我取出 docker-compose.yml 文件中的$ c>和 entrypoint 部分,然后容器启动也没有问题,甚至尽管在我看来错误是原始图像造成的。

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?

推荐答案

我在您的图像中认为 docker-remote .registry.kroger.com / mattermost / mattermost-preview 不存在文件夹 / mm / mock-mount

i think in your image docker-remote.registry.kroger.com/mattermost/mattermost-preview not exist folder /mm/mock-mount.

尝试将入口点更改为

入口点:/ bin / bash -c /mm/mock-mount/docker-entry.sh

这篇关于无法通过docker-compose向图像添加体积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆