How to see the logs of docker container running on different ports - docker

I am running single docker container on two different ports using below command
docker run -p ${EXTERNAL_PORT_NUMBER}:${INTERNAL_PORT_NUMBER} -p ${EXTERNAL_PORT_NUMBER_SECOND}:${INTERNAL_PORT_NUMBER_SECOND} --network ${NETWORK} --name ${SERVICE_NAME} --restart always -m 1024M --memory-swap -1 -itd ${ORGANISATION}/${SERVICE_NAME}:${VERSION}
I can see the container is running fine
My question is How can I see the logs of this docker container.
Every time I do sudo docker logs database-service -f I can see the log of container running on 9003 port only.
How can I view the logs of container running on 9113

You are getting all the logs that was displayed on stdout or stderr in the container.
It has nothing to do with the processes which are exposed on different ports.
If 2 instance is running inside the container and both are showing there logs on system console then you will be getting both logs on the docker logs command for the container.
You can try multitail utility to tail more than one log files in docker exec command.
For that you have to install it in that container.

You can bind external volumes to container service logs and see the logs
docker run -v 'path_to_you_host_logs':'container_service_log_path'
docker run -v 'home/user/app/apache_access.log':
'/var/log/apache_access.log'

Related

Jenkins docker running in the container but not launching in web browser

On my Redhat7linux docker host, i have created a jenkins container by pulling the jenkins official image from docker hub and i was able to bring the jenkins container up & running by executing the command:
docker run -d -p 50000:8080 -v $PWD/jenkins:/var/lib/jenkins -t jenkins_master
and i could see the jenkins is up when i checked the logs using the docker logs {containerID} but when i try to launch it in web browser with {hostip}:50000, I couldn't access it as it throws "The site cant be reached", and since my container is running inside a company network, should I either open/enable that port 50000 or do I need to set any proxy in the docker host?
Am I missing something here?
Here are the outputs of the docker command:
The official image provide the following command :
docker run -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins
It seems that both ports 8080 and 50000 have to be exposed.
Execute the docker run command to run the container, check the status of your container.
docker container run -p [YOUR PORT]:8080 -v [YOUR
VOLUME]:/var/jenkins_home
--name jenkins-local jenkins/jenkins:lts
you can then access it using localhost:[YOUR PORT]

Cannot run RabbitMQ via Docker

What do I do wrong?
run as command
docker run -d --name rabbitmq_awr -p 5672:5672 -p 5673:5673 -p 15672:15672 rabbitmq:3-management
but http://localhost:15672/ didn't launch in browser
log below
First:
Make sure that your radditMQ instance is running by doing docker ps.
and if it is listed in the running containers.
Find out on which IP it is running on by using docker network inspect
Get that IP and launch it into your browser instead of localhost.
Second
If your container is not listed when you run docker ps, find out from the logs it issues using docker logs <container-name or id> whats causing the container to fail.

Run a .war on a Docker container

I'm running a Java web application on a Docker cluster running those commands:
PS C:\Users\Marco\test_workspace> docker run -v test_web_application.war:/usr/local/tomcat/webapps/TestWebApplication.war -it -p 8080:8080 --network "host" -d Tomcat
The actual output confirms that the container is running:
At this point i want to access to the container through it's IP address from my host and i'm using the command inspect to identify the IP:
But, as the screenshot shows, i don't see any IP assigned.
Thus, my questions are:
Why the command --network "host" to assign an IP address shared with the host didn't worked ?
Finally, how can i access to my web application from the host ?
Command option --network="host" isn't supported for Docker for Windows (more information: https://docs.docker.com/network/host/).
You can access your application on localhost:8080 with launch option -p 8080:8080.

No such image or container error

I want to setup a rancher server and a rancher agent on the same server.
Here is what i have done for creating server:
docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:stable
Then, I have opened my web-browser on 8080 port.
I have chosen a login/password and enabled access control.
Then i wanted to create a host (agent). Rancher web interface says me to type this command:
docker run -e CATTLE_AGENT_IP=x.x.x.x --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://nsxxx.ovh.net:8080/v1/scripts/yyyy:1514678400000:zzzz
I have no error message, but I do not see any entry in host section (in rancher web interface).
So I tried to execute a shell on the agent docker container:
docker exec -ti xxxxx /bin/bash
I tried to manually run run.sh script and here is what I see:
Error: No such image or container: nsxxx
I suppose this is because docker containers cannot communicate together, but I have done exactly what is in the documentation...
Thanks for your help
For docker exec your need to replace the xxxxx string with the container id or the name of the container. Both you get from the docker ps command

Docker in Docker: Port Mapping

I have found a similar thread, but failed to get it to work. So, the use case is
I start a container on my Linux host
docker run -i -t --privileged -p 8080:2375 mattgruter/doubledocker
When in that container, I want to start another one with GAE SDK devserver running.
At that, I need to access a running app from the host system browser.
When I start a container in the container as
docker run -i -t -p 2375:8080 image/name
I get an error saying that 2375 port is in use. I start the app, and can curl 0.0.0.0:8080 when inside both containers (when using another port 8080:8080 for example) but cannot preview the app from the host system, since lohalhost:8080 listens to 2375 port in the first container, and that port cannot be used when launching the second container.
I'm able to do that using the image jpetazzo/dind. The test I have done and worked (as an example):
From my host machine I run the container with docker installed:
docker run --privileged -t -i --rm -e LOG=file -p 18080:8080
jpetazzo/dind
Then inside the container I've pulled nginx image and run it with
docker run -d -p 8080:80 nginx
And from the host environment I can browse the nginx welcome page with http://localhost:18080
With the image you were using (mattgruter/doubledocker) I have some problem running it (something related to log attach).

Resources