我有一个现有的docker-compose文件
version: '3.6'
services:
verdaccio:
restart: always
image: verdaccio/verdaccio
container_name: verdaccio
ports:
- 4873:4873
volumes:
- conf:/verdaccio/conf
- storage:/verdaccio/storage
- plugins:/verdaccio/plugins
environment:
- VERDACCIO_PROTOCOL=https
networks:
default:
external:
name: registry
我想使用DockerFile而不是docker-compose,因为在Azure容器注册表上部署DockerFile会更容易。
我已经尝试过许多在博客和其他网站上发布的解决方案,但没有按需使用的方法。
如何从上面的docker-compose文件创建简单的DockerFile?
If you want to put
conf
,storage
andplugins
files/folders into image, you can just copy them:但是,如果您需要保留文件/文件夹的更改,则应保持它们现在的状态。
You can't. Many of the Docker Compose options (and the equivalent
docker run
options) can only be set when you start a container. In your example, the restart policy, published ports, mounted volumes, network configuration, and overriding the container name are all runtime-only options.If you built a Docker image matching this, the most you could add in is setting that one
ENV
variable, andCOPY
ing in the configuration files and plugins rather than storing them in named volumes. The majority of thatdocker-compose.yml
would still be required.