1

I want to write the equivalent of the following in docker-compose.yaml.

How can I do that?

docker run -it myImage
Pero122
  • 892
  • 11
  • 25

1 Answers1

2

You actually have 2 flags:

  • i - Keep STDIN open even if not attached
  • t - Allocate a pseudo-TTY

So we just need to find the right keys to put in docker-compose.yaml (tty & stdin_open)

version: "3.9" #you can put you own version
services:
  yourServiceName:
    image: yourImageName
    tty: true               # equivalent for -t
    stdin_open: true        # equivalent for -i

Now you can use docker-compose up to run your container (or docker-compose start if you already have a created container)

More info about other flags (LINK)

Mime
  • 1,142
  • 1
  • 9
  • 20
Pero122
  • 892
  • 11
  • 25