docker-compose - 无法附加到容器

时间:2016-01-08 02:02:04

标签: postgresql ubuntu docker docker-compose

如果我运行“docker-compose.yml”或“docker-compose up”命令,请使用下面的docker-compose up -d文件,然后我会将两个容器状态视为已退出,但是当我运行docker restart <postgres-containerId>时,它会启动并且当我尝试运行docker restart <java8-containerId>然后重新启动并再次退出时。

您能否建议我在containers up and running命令和docker-compose up how do I attach to java container后使用docker attach <java8-containerId>命令我需要指定哪个参数,但我无法附加?

docker-compose.yml file -

postgres:
  image: postgres:9.4
  ports:
   - "5430:5432"

javaapp:
  image:java8:latest
  volumes:
   - /pgm:/pgm
  working_dir: /pgm
  links:
   - postgres
  command: /bin/bash

docker-compose ps results -
       Name                     Command               State    Ports 
--------------------------------------------------------------------
compose_javaapp_1    /bin/bash                        Exit 0         
compose_postgres_1   /docker-entrypoint.sh postgres   Exit 0     

1 个答案:

答案 0 :(得分:2)

查看可用容器:

docker ps -a

打开容器shell:

docker exec -it <container-name> /bin/bash