I am trying to build services using docker-compose but containers started using docker-compose is stopping immediately as compose script is over. But when i am creating container using docker run for the same service image it is working.
Here is my compose script:
version: '2.1'
networks:
composetestnetwork:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.19.0.0/16
gateway: 172.19.0.1
services:
composetestdb:
build:
context: .
dockerfile: Dockerfile-testdb
cap_add:
- ALL
container_name: my-db-compose-container
labels:
db.description: "This is a test db"
volumes:
- c:/Users:/data
networks:
composetestnetwork:
ipv4_address: 172.19.0.5
ports:
- "3306:3306"
command: 'bash'
What can be done to fix this.
If you use bash
as the command
, but without a terminal, it will exit immediately. This is because when bash starts up, if there is no terminal attached, and it has no script or other command to execute, it has nothing to do, so it exits (by design).
You can either use a different command
, or attach a terminal with tty: true
as part of the definition of this service.
services:
composetestdb:
tty: true
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With