简体   繁体   中英

Can not start Docker container

I created ubuntu image using docker-compose . Here is the relevant code from docker-compose.yml :

ubuntu-os:
  container_name: ubuntu
  image: ubuntu
  volumes:
    - ubuntu-datavolume:/home/username/docker/.os/ubuntu/
volumes:
  ubuntu-datavolume:

It gets stopped as soon as it is started. I can not interract with the container. Here is relevant docker ps -a :

03dae5416b67    ubuntu    "/bin/bash"    12 minutes ago    Exited (0) 3 minutes ago    ubuntu

I have tried every possible combo of docker start -a ubuntu but with no luck. I want this image to persist data across restart so I created the volume. Any suggestions?

Creating a new container is not what I am looking for but to start the existing container. I don't want to run the container but start and interact.

You use a ubuntu image which have an entry point /bin/sh . If you launch this without interactive/terminal linked, it will just run and exit with code 0. Your container finish successfully.

You can add the option:

  stdin_open: true
  tty: true

Referenced https://docs.docker.com/compose/compose-file/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir

or add command line that do something. like: command: sleep 600000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM