Wednesday, September 11, 2019

Docker: Container Logging



docker container run --name weather-app -d -p 80:3000 linuxacademycontent/weather-app

docker container ls

docker container logs container_id

docker container logs container_id

docker container run -d --name ghost_blog \
-e database__client=mysql \
-e database__connection_host=mysql \
-e database__connection_user=root \
-e database__connection_password=password \
-e database__connection_database=ghost \
-p 8080:2368 \
ghost:1-alpine

docker container ls

docker container ls -a

docker container logs container_id

===Summary===
Create a container using the weather-app image.
docker container run --name weather-app -d -p 80:3000 linuxacademycontent/weather-app
Show information logged by a running container:
docker container logs [NAME]
Show information logged by all containers participating in a service:
docker service logs [SERVICE]
Logs need to be output to STDOUT and STDERR.
Nginx Example:
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
    && ln -sf /dev/stderr /var/log/nginx/error.log
Debug a failed container deploy:
docker container run -d --name ghost_blog \
-e database__client=mysql \
-e database__connection__host=mysql \
-e database__connection__user=root \
-e database__connection__password=P4sSw0rd0! \
-e database__connection__database=ghost \
-p 8080:2368 \
ghost:1-alpine