Docker container log does not appear anymore on Docker compose log - docker

I'm running my Docker container through my Docker compose, but when my container stops and it restarts again, the log does not appear anymore related to this restarted container.
Would anyone know how to fix it?
I send below the docker compose command and the file for analysis.
Thank you in advance.
Command to start the compose
docker-compose -f docker-compose.dev.yml up
Docker compose
version: '3'
services:
ms3_executive_back:
image: ms3_executive_backend
ports:
- "5001:5001"
volumes:
- ./executive_backend:/app
restart: always

If you want to inspect the logs to determine cause of failure, you can try setting your restart: "no". This will ensure that docker-compose does not automatically restart your container and overwrite the existing logs.

Related

Error in docker: network "path" declared as external, but could not be found

I am new to docker. I have been assigned with a task that uses Docker container for development. I followed the tutorial for installing the Docker and the containers on Windows 10, but I have the following error: network remaxmdcrm_remaxmd-network declared as external, but could not be found
The steps I've done so far are:
Cloned the repository from GitHub.
Installed Docker on my laptop.
Once I installed Docker, I went in the root of my project and ran the following command. docker-compose build -d -t docker-compose.yml - docker-compose.yml being the file in the root dir.
I opened Docker app and I ran the images created.
I ran the command docker-compose up. When I ran this command, the error I specified at the beginning appears. network remaxmdcrm_remaxmd-network declared as external, but could not be found
docker-compose.yml
services:
ui:
build:
context: .
dockerfile: Dockerfile.development
volumes:
- .:/app
ports:
- "5000:5000"
restart: unless-stopped
networks:
- remaxmdcrm_remaxmd-network
redis:
image: 'redis:alpine'
networks:
- remaxmdcrm_remaxmd-network
networks:
remaxmdcrm_remaxmd-network:
external: true
Ran: docker ps -a
ID IMAGE
5e6cf997487c remaxmd-site_ui:latest
451009e0a2a6 redis:alpine
85e7cde67d05 docmer-compose.yml:latest
I might do something wrong here. Can somebody help me? I much appreciate your time!
I solved the issue, finally. The issue came from the fact that I had in docker-compose.yml remaxmdcrm_remaxmd-network declared as external. The external network was not created during installation, thus I needed to create a bridging network.
I ran the command docker network create "name_of_network"
For further details, here is the full documentation this
You can see docker network ls and uses bridge network
You shouldn't have to run a command to create the network prior to running docker compose, Docker should create the network if it doesn't exist. The reason you're getting this error is because you're declaring the network as external, which means that Docker expects it to already exist. If you need a new one, remove external: true

Why container based on ubuntu didn't run from docker-compose file, when that work for similar nginx container? [duplicate]

This question already has answers here:
Ubuntu container keep restarting
(1 answer)
How can I run bash in a new container of a docker image?
(1 answer)
Docker compose detached mode not working
(2 answers)
Closed 1 year ago.
I try to run docker container using docker-compose file instead of a long command line.
I want to run docker-compose file based on ubuntu:latest. Container created but can't run.
version: "3.9"
services:
ubuntu:
image: ubuntu:latest
container_name: nginx_from_scratch3
ports:
- "80:80"
But before I've tried add in my docker-compose file line
command: bash
And noting change. I think what after running container continue to work. But that didn't happend.
But on the other side if I use nginx image all run perfectly.
version: "3.9"
services:
nginx1:
image: nginx
container_name: nginx_from_scratch4
ports:
- "80:80"
Why docker-compose file for nginx image work, and doesn’t work for ubuntu image.
Docker container exits if task inside is done. So when you run nginx, it starts nginx automatically and keep it alive. As for ubuntu, there's no any task to keep running and container ended immediately. So if you want to keep it alive even if it does not have any job: add tail -f, like this:
version: "3.9"
services:
ubuntu:
image: ubuntu
command: tail -F anything
After you do docker container ps you will see it running.
And you can move to it with
docker exec -it container_name bash

Restart Docker Container with new Image

One of my Docker Containers can update itself (talking to the Docker Daemon using the Spotify Docker Client). After downloading the new image a container restart is required, with the new iamge of course.
If I just kill the running process inside the container, Docker restarts it using the old image. Is there any reliable way to force recreating the container using the new image? Couldn't find anything in the docker-compose docs. It's a single host environment only, no Kubernetes or something like that in use.
Compose file snippet:
dockerctl:
image: myimage
container_name: dockerctl
networks:
- mynetwork
ports:
- "8099:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
Bit of an old question, but this should do it: Update the image name in your docker-compose.yml and restart it by running docker-compose up -d --no-deps dockerctl.

Why docker restart recognizes modifications in docker-compose.yml file

I am new in docker and docker-compose. I am working on a project which uses both docker and docker compose. After adding a line in the key "volumes" of docker-compose.yml. I did docker restart
docker restart service1
and the volume was automatically recognized. Below part of the docker-compose.yml
services:
service1:
build:
context: .
dockerfile: Dockerfile.service1
container_name: service1_name
hostname: service1_name
volumes:
- /etc/teste/service1/conf.d/:/usr/share/logstash/pipeline/ #I added this line
My question Why docker restart recognizes modifications in docker-compose.yml file, where can I find this "setting"?
Working with docker-compose the scenario should be the following:
Create your docker-compose.yml
docker-compose up # this will build everything and run your services
If you make any changes to your compose file, stating docker-compose build 'yourservicename' will rebuild that specific service.
The command "docker restart" as you can see in the help page is for restarting containers

docker-compose up not recreate container

I create two containers, one is an oracle db and one is an apache tomcat.
I run both of them using the following docker compose:
version: '3.4'
services:
tomcat:
build: ./tomcat/.
ports:
- "8888:8080"
- "59339:59339"
depends_on:
- oracle
volumes:
- ./tomcat/FILES:/usr/test/FILES
- ./ROOT.war:/opt/tomcat/webapps/ROOT.war
expose:
- "8888"
- "59339"
oracle:
build: ./database/.
ports:
- "49161:1521"
environment:
- ORACLE_ALLOW_REMOTE=true
expose:
- "49161"
I use the command docker-compose up that in according with the documentation it must be recreate the container.
But in reality it start only the old containers (same containers ID) with the state of the containers when it was stoped, this is a problem because I use it for testing and I want to start from a clean situation (ROOT.war must be deployed every time i run the command).
It is normal or I miss something.
I'm using docker for windows 18.06.1-ce and Compose 1.22.0
UPDATE
So is not true that up recreate container but do it only if something changed?
I also see docker-compose down that remove the container and force up to recreate them, is the right approch?
The things that I not uderstand is why the status of the container was saved every time i stoped it (file app.pid create by tomcat still present after a simple up without a previous down)
docker-compose starts and stops containers, if you want to recreate them every time you have to pass the --force-recreate flag as per the docs.
Yes, this is as expected.
Sounds like you want to do a restart:
docker-compose restart
or to force a rebuild:
docker-compose --build start
--force-recreate will recreate the contianers
From Docs
--force-recreate => Recreate containers even if their configuration and image haven't
changed.
docker-compose up -d --force-recreate

Resources