[英]Docker ps doesn't show containers created/runing with docker-compose
I'm trying to understand why I can't see containers created with docker-compose up -d using docker ps .我试图理解为什么我看不到使用docker-compose up -d使用docker ps创建的容器。 If I go to the folder where is the docker-compose.yaml located and run docker-compose ps I can see the container runing.
如果我 go 到docker-compose.yaml所在的文件夹并运行ZBAEDB53E845AE71F13945FCC005可以看到容器运行 ZBAEDB53E845AE71F13945FCC005 I did the same on windows because i'm using ubuntu and it works as expected, I can see the container just runing docker ps.
我在 windows 上做了同样的事情,因为我正在使用 ubuntu 并且它按预期工作,我可以看到容器刚刚运行 docker ps。 Could anyone give me a hint about this behavior, please?
谁能给我一个关于这种行为的提示,好吗? Thanks in advance.
提前致谢。
Environment:
Docker version 20.10.17, build 100c701
docker-compose version 1.25.0, build unknown
Ubuntu 20.04.4 LTS
in my terminal i see this output:在我的终端中,我看到了这个 output:
/GIT/project$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
/GIT/project$ cd scripts/
/GIT/project/scripts$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
/GIT/project/scripts$ docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------------------------
scripts_db_1 docker-entrypoint.sh --def ... Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp,
33060/tcp
/GIT/project/scripts$
docker-compose.yaml docker-compose.yaml
version: '3.3'
services:
db:
image: mysql:5.7
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
# (this is just an example, not intended to be a production configuration)
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
# <Port exposed> : < MySQL Port running inside container>
- 3306:3306
expose:
# Opens port 3306 on the container
- 3306
# Where our data will be persisted
volumes:
- treip:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: changeit
MYSQL_DATABASE: treip
volumes:
treip:
Runing the container with sudo i can see the container using docker ps
, so instead of docker-compose up
I runned it with sudo sudo docker-compose up
.使用 sudo 运行容器我可以看到使用
docker ps
的容器,所以我使用 sudo sudo docker-compose up
而不是docker-compose up
运行它。 Sorry, my bad.对不起这是我的错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.