Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output or log to docker-compose output?

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.

like image 212
jonnie Avatar asked Jul 29 '16 17:07

jonnie


People also ask

How do you communicate with Docker compose?

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.

Does docker have a log file?

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.


1 Answers

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
like image 199
BMitch Avatar answered Nov 02 '22 17:11

BMitch