Convert a typical nginx run command with port, volume, environment, and restart
- Docker Run Command
- docker run -d --name nginx_web -p 8080:80 -v /my/custom/nginx.conf:/etc/nginx/nginx.conf:ro -e NGINX_PORT=80 --restart always nginx:latest
- Compose Version
- Version 3.8
- Input: docker run -d --name nginx_web -p 8080:80 -v /my/custom/nginx.conf:/etc/nginx/nginx.conf:ro -e NGINX_PORT=80 --restart always nginx:latest
- Select Compose version 3.8.
- The converter parses the flags and generates YAML whose service takes its name from the container name, with the nginx:latest image, the same container name, restart set to always, the 8080:80 port mapping, the read-only configuration file volume, and the port environment variable set to 80.
- docker-compose.yml
- version: '3.8' services: nginx_web: image: nginx:latest container_name: nginx_web restart: always ports: - "8080:80" volumes: - /my/custom/nginx.conf:/etc/nginx/nginx.conf:ro environment: - NGINX_PORT=80
The output is a valid Compose file for version 3.8. Note that the volume path is used as-is; if it is a host path, it must exist on the Docker host.
