The docker compose yml file below keeps the container open after I run docker compose up -d
but command: bash
does not get executed:
version: "3.8"
services:
service:
container_name: pw-cont
image: mcr.microsoft.com/playwright:v1.30.0-focal
stdin_open: true # -i
tty: true # -t
network_mode: host # --network host
volumes: # Ensures that updates in local/container are in sync
- $PWD:/playwright/
working_dir: /playwright
command: bash
After I spin the container up, I wanted to visit Docker Desktop > Running container’s terminal.
Expectation: Since the file has command: bash
, I expect that in docker desktop, when I go to the running container’s terminal, it will show root@docker-desktop:/playwright#
.
Actual: Container’s terminal in docker desktop is showing #
, still need to type bash
to see root@docker-desktop:/playwright#
.
Can the yml file be updated so that bash
gets auto executed when spinning up the container?
2
Answers
docker compose
doesn’t provide that sort of interactive connection. Yourdocker-compose.yaml
file is fine; once your container is running you can attach to it usingdocker attach pw-cont
to access stdin/stdout for the container.I’m not sure what you are trying to achieve, but using the
run
commandgives me the prompt you expect.