Docker:使用docker-compose复制文件和目录

I created one Docker Image for a custom application which needs some license files (some files and one directory) to run, so I'm using the COPY command in the Dockerfile to copy license file to the image:

# Base image: Application installed on Debian 10 but unlicensed
FROM me/application-unlicensed

# Copy license files
COPY *.license /opt/application/
COPY application-license-dir /var/lib/application-license-dir

I use this Dockerfile to build a new image with the license for a single container. As I have 5 different licenses I created 5 different images each with one specific license file and directory.

The licenses are also fixed to a MAC Address, so when I run one of the five container I specify its own MAC Address with the --mac-address parameter:

docker run --rm --mac-address AB:CD:EF:12:34:56 me/application-license1

这项工作,但我希望有一种更好,更聪明的方式来管理:

As with docker-compose is it possible to specify the container MAC Address, could I just use the unlicensed base image and copy license files and the license directory when I build the 5 containers with docker-compose?

评论
  • 请,带走
    请,带走 回复

    You can set mac_address for the different containers as mac_address: AB:CD:EF:12:34:12. For documentation reference see this

    为了从同一张图片创建多个实例,您必须将每个应用程序块复制粘贴到docker-compose文件中5次,并且每次设置中可以设置不同的mac_adddress

  • fdolor
    fdolor 回复

    According to this commit docker-compose has mac_address support. Mounting license files with -v could be an option.