高频使用命令之考考你自己
- 登入容器
高频使用命令答案(用更好的吗?)
- 登入容器
docker exec -it dnmp-php56 /bin/bash
- 重启容器
docker restart dnmp-nginx
重新构建容器
修改完 docker-compose.yml 配置文件,如:php56对应 配置项,重新构建。
docker-compose build php56
镜像
获取镜像的详细信息
通过 docker inspect
命令,我们可以获取镜像的详细信息,其中,包括创建者,各层的数字摘要等。
查看所有容器的ip
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
This command allows you to view the IP of all containers opened with docker-compose. The result is similar to the figure below, and you can use the corresponding IP address for internal communication.
https://developpaper.com/docker-builds-php-nginx-swoole-mysql-redis-environment/
在php中连接redis容器时需要用到,也可以使用容器名连接,如:dnmp-redis