docker-compose, new container version and logs persistence

Quite common use-case with docker-compose:

  • A application’s code pulled from a repository using git.
  • A docker-compose.yml looking like this:


version: '2'
services:
web:
build: ./myapp

  • How can I access from outside my docker container in mac?
  • Docker container doesn't expose ports when --net=host is mentioned in the docker run command
  • Docker hub/registry automated build from github build details log
  • How is non-volume data for a Docker container stored?
  • Not able to connect to mongodb replica set running in docker in different machine
  • Docker: Host not found in upstream app:9000
  • When I want to deploy a new version I just pull the latest version of my code then make a docker-compose up --build -d.

    Works almost perfectly except each time I make an update it erases my past logs accessible using docker-compose logs. I understand why docker behaves that way (even if docker-compose recreates a container with the same name it’s still a brand new container, so it’s quite logical logs get flushed). Still, it’s really not practical.

    Any one has a solution for that ? Preferably one that does not involve modifying images or using volumes to store logs. (Because that should be the whole point of docker logs, not having to worry about that).

  • How do I use EBS volume with ECS container
  • ElasticBeanstalk: storing a bullet proof docker container
  • Access host IP inside docker container using docker-compose
  • Convert Docker Compose to a service create command
  • Unable to list kafka topics in openwhisk setup
  • Test Commands are not recognised in Django
  • 2 Solutions collect form web for “docker-compose, new container version and logs persistence”

    You could redirect the output to a log file when starting the containers, something like:

    docker-compose up --build --no-color --force-recreate &> logs &
    

    Instead of docker-compose logs you could tail logs anytime you want.

    I think your best bet is to use one of the Logging Driver options described on the Docker docs:
    https://docs.docker.com/engine/admin/logging/overview/

    If this isn’t a workable solution, can you give me a little more context for your goals and obstacles?

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.