Jamesla
Jamesla

Reputation: 1408

Convert a docker run statement into a docker-compose.yml file

I have the following image that works great via the command

docker run my-hello-world echo hello!

Obviously a contrived example however how can I convert this into a small docker-compose.yml file? docker-compose doesn't appear to have a run command. Can it not run containers???

Upvotes: 2

Views: 1080

Answers (2)

Shōgun8
Shōgun8

Reputation: 562

You can just paste your run command to this website and let it do the work for you!

https://composerize.com/

Upvotes: 0

Janshair Khan
Janshair Khan

Reputation: 2687

You can run container's command with Docker Compose and provision containers. But you don't use docker run instead you use docker-compose up and down to up and down containers. In this case, try create a docker-compose.yml file with the contents:

version: '2'

services:
 app1:
  image: my-hello-world
  command: "echo hello!"

Upvotes: 2

Related Questions