docker logs 容器id
version: "2.0" services: nginx: image: nginx:latest ports: - "80:80" volumes: - ~/Projects/sh-valley/docker-conf/lnmp/nginx/www:/usr/share/nginx/html - ~/Projects/sh-valley/docker-conf/lnmp/nginx/conf:/etc/nginx/conf.d - ~/Projects/sh-valley/docker-conf/lnmp/nginx/logs:/var/log/nginx networks: - lnmp-network php: image: php:latest volumes: - ~/Projects/sh-valley/docker-conf/lnmp/nginx/www:/www stdin_open: true tty: true networks: - lnmp-network mysql: image: mysql:latest ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=123456 networks: - lnmp-network networks: lnmp-network:
如果不加入 stdin_open 和 tty 这二行代码会导致容器起不来,并且docker logs php_wordpress 后出现:
Interactive shell