'How to convert docker command to docker-compose

I wanted to convert docker run command to docker compose. Can you plz give some clue.

docker run -dit -h nginx --name=nginx --net=internal -p 8085:80 --restart=always -v /default.conf:/etc/nginx/conf.d/default.conf nginx:latest



Solution 1:[1]

Use docker run --help to understand what each of the used options does. Then proceed to the Compose file reference and find there how it is configured with YAML.

Note that some command line arguments have no equivalents in compose. That is either because they are not yet implemented or because they are also used as command line options. An example of the latter is -d, which run the container in detached mode. Its equivalent for docker-compose is also -d (e.g docker-compose up -d).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1