When I run docker-compose up it logs some information to the terminal and I would like to know where this information is coming from and how I might log to it.For example I would like to output each request in a php application within the container. I have tried to look online including the docker docs but have had no luck.
Create an external network with docker network create <network name> In each of your docker-compose. yml configure the default network to use your externally created network with the networks top-level key. You can use either the service name or container name to connect between containers.
The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.
The output in docker-compose
is the stdout/stderr from the command the container runs. You see this with docker run
if you don't detach, and you can get this from docker logs
on a container you're detached from or docker-compose logs
from a compose submitted group of containers.
Edit: evidence of this behavior:
$ cat docker-compose.hello-world.yml
version: '2'
services:
hello-world:
image: busybox
command: "echo hello world"
$ docker-compose -f docker-compose.hello-world.yml up
Creating test_hello-world_1
Attaching to test_hello-world_1
hello-world_1 | hello world
test_hello-world_1 exited with code 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With