英文:
Converting Docker create command into docker-compose file
问题
I need to convert this to a DockerFile, and have no idea where to start, could someone help me out please?
FROM <base_image>
# Set environment variables
ENV PUID=1001
ENV PGID=1001
# Create directories
RUN mkdir -p /config /mnt/<My_Vol_1> /mnt/<My_Vol_2> /mnt/<My_Vol_3> /downloads
# Copy files
COPY <dockerInstance> /config
COPY <dockerInstance> /downloads
# Expose ports
EXPOSE <PORT>
CMD ["your_command"]
Please replace <base_image>
, <PORT>
, <dockerInstance>
, and <My_Vol_X>
with the appropriate values for your setup.
英文:
I need to convert this to a DockerFile, and have no idea where to start, could someone help me out please?
docker create --name=<NAME> --restart=always -p <PORT>:<PORT> -e PUID=1001 -e PGID=1001 -v /dev/rtc:/dev/rtc:ro -v /var/lib/<dockerInstance>:/config -v /mnt/<My_Vol_1>:/mnt/<My_Vol_1> -v /mnt/<My_Vol_2>:/mnt/<My_Vol_2> -v /mnt/<My_Vol_3>:/mnt/<My_Vol_1> -v /mnt/<My_Vol_4>:/downloads <dockerInstance>
答案1
得分: 1
根据您提供的内容,以下是翻译好的部分:
你所提供的内容,你需要的不是一个Dockerfile,而是一个docker-compose文件。你在这里的命令创建了一个容器,这个容器需要一个镜像才能运行。
一个Dockerfile允许你创建一个包含一组指令的镜像。
一个Docker compose文件允许你以多个参数运行这个镜像(或多个镜像),比如要暴露的端口。
在你的情况下,可以是这样的:
version: "3.9"
services:
<NAME>:
image: <IMAGE>
container_name: <NAME>
ports:
- "<PORT>:<PORT>"
之后你可以使用 docker compose up
来运行你的容器。
这并不是完整的转换你的命令的文件,但是这是一个很好的开始。
关于Docker Compose的文档请参考这里。
英文:
With what you gave, what you need is not a Dockerfile but a docker-compose file. Your command here creates a container which needs an image to be able to run.
A Dockerfile allows you to creates an image that contains a set of instructions.
A Docker compose file allows you to run this image (or multiple images) with multiple parameters like the ports to expose.
In your case, it could be :
version: "3.9"
services:
<NAME>:
image: <IMAGE>
container_name: <NAME>
ports:
- "<PORT>:<PORT>"
You can use docker compose up
after that to run your container.
It's not the complete file to convert your command but it's a good way to start.
See here for the documentation about the docker compose.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论