Configuration issue in nginx of docker - Troubleshooting docker with no instaces - bash

When there was a configuration problem and docker instance is not coming up, how to do the troubleshooting ..
RajRajen:lb4b-my rajrajen$ docker run -d -t -i -p 80:80 -p 443:443 --name my_nginx_v4 my_nginx_v4
f459a9d666f1596dd77c1095b7256075b183fe8b7997c17e8f7b1640606bb075
RajRajen:lb4b-my rajrajen$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
RajRajen:lb4b-my rajrajen$ docker ps
Results in NO Result. How to identify the reason for the failure. There are many links if there is a running instance.
docker exec -ti /bin/bash
Ref : https://askubuntu.com/questions/505506/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode
Thanks

Just gave a try to find whats in
When there was a configuration problem and docker instance is not coming up, how to do the troubleshooting ..
RajRajen:lb4b-my rajrajen$ docker log
5139b2417a39563a3848cc796b6c572d6508c0b862c4d13dceac9d59b3936420
And this log message is available
RajRajen:lb4b-fe rajrajen$ docker logs 5139b2417a39563a3848cc796b6c572d6508c0b862c4d13dceac9d59b3936420
2015/11/27 01:11:58 [emerg] 1#1: unknown "redir_match" variable
nginx: [emerg] unknown "redir_match" variable
This hint helped to resolve the issue .
Thanks ...

Just gave a try to find whats in it.
When there was a configuration problem and docker instance is not coming up, how to do the troubleshooting ..
A) Identify the instance
RajRajen:lb4b-my rajrajen$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1a03bab01e40 lb4b-my "tail -f /dev/null" 7 minutes ago Excited(1) gc_lb4b-my
And this hidden container id helps to figure out further issue.
B) yet thats not enough to troubleshoot further issues inside the application
So, did the following to keep the docker running and then go inside the docker and execute the command that fails manually.
docker run -d -P --name gc_lb4b-my fe_lb4b-my tail -f /dev/null

Related

docker images listed, but not able to delete

i am trying to run container using image, but it doesn't detect image locally. whereas the images are listed as shown below. To recover i thought of deleting and re-running. But, i get error in deleting the listed image:
Also, I will like to highlight that i have uninstalled and re-installed docker between first time and 2nd time running the below cmd to start container.
Here is the sequence of steps i have done:
Command to run container (which downloaded image when i ran it first)
docker container run --name jenkins-docker --rm --detach \
> --privileged --network jenkins --network-alias docker \
> --env DOCKER_TLS_CERTDIR=/certs \
> --volume jenkins-docker-certs:/certs/client \
> --volume jenkins-data:/var/jenkins_home \
> --volume "$HOME":/home docker:dind
Uninstalled and re-installed docker
Re-run above cmd to start conatiner (got below error)
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
list image
REPOSITORY TAG IMAGE ID CREATED SIZE
jenkinsci/blueocean latest b9a3e09d0e84 22 hours ago 549MB
docker dind 8489eeb24a26 4 days ago 237MB
Validate that no container is running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Deleting images :
Error: No such image: b9a3e09d0e84
docker rmi 8489eeb24a26
Error: No such image: 8489eeb24a26
to force delete all containers, run:
docker rm -f $(docker ps -a -q)
to force delete all images, run:
docker rmi -f $(docker images -a -q)
to check containers have been deleted, run:
docker ps -a
to check images have been deleted, run
docker images -a
you can see errors like following at image deletion time, but you'll see by running docker images -a that there is nothing left
Error: No such image: 1203fc0eeda3
Had a similar issue where podman created an image duplicate listed as
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> b6513bbf3672 7 minutes ago 116 MB
Force deleting with
docker rmi -f $(docker images -a -q)
as suggested by fredericrous solved it!

is there any way to run a docker image on host from other docker image? [duplicate]

I am using a docker container to build and deploy my software to a collection of ec2's. In the deployment script I build my software and then package it in a docker image. The image is pushed to my private registry, pulled by my production ec2's and then run. So essentially I will need to run docker within a docker container.
The problem is that I can't actually start docker on my container. If I try
service docker start
I get
bash: service: command not found
And if I try
docker -d
I get
2014/10/07 15:54:35 docker daemon: 0.11.1-dev 02d20af/0.11.1; execdriver: native; graphdriver:
[e2feb6f9] +job serveapi(unix:///var/run/docker.sock)
[e2feb6f9] +job initserver()
[e2feb6f9.initserver()] Creating server
2014/10/07 15:54:35 Listening for HTTP on unix (/var/run/docker.sock)
[error] attach_loopback.go:42 There are no more loopback device available.
loopback mounting failed
[e2feb6f9] -job initserver() = ERR (1)
2014/10/07 15:54:35 loopback mounting failed
The service command doesn't exist on the docker container so I can't start docker. I'm not sure what I should be doing now to start docker so I'm a bit stuck here, any help is appreciated.
A bit more information
Host machine is running fedora 20 (will eventually be running amazon linux on an ec2)
Docker container is running centos 7.0
Host is running Docker version 1.2.0, build fa7b24f/1.2.0
Container is running docker-0.11.1-22.el7.centos.x86_64
How about not running 'docker inside docker' and run docker on your host, but from within your docker container? Just mount your docker.sock and docker binary:
docker run -v /var/run/docker.sock:/run/docker.sock -v $(which docker):/bin/docker [your image]
https://github.com/sameersbn/docker-gitlab uses this approach to spin up docker containers, take a look at this image.
You can also take a look at: https://registry.hub.docker.com/u/mattgruter/doubledocker/
UPDATE on july 2016
The most current approach is to use docker:dind image, as described here:
https://hub.docker.com/_/docker/
Short summary:
$ docker run --privileged --name some-docker -d docker:dind
and then:
$ docker run --rm --link some-docker:docker docker info
While in almost all cases I would suggest following #cthulhu's answer and not running "docker in docker", in the cases when you must (e.g. a test suite which tests against multiple docker version), use the following to create additional loopback devices:
#!/bin/bash
for i in {0..6}
do
mknod -m0660 /dev/loop$i b 7 $i
done
(Taken from the thread for Docker Issue #7058)
You can simply run docker inside the docker container using dind. Try this image from Jerome, as follows:
docker run --privileged -t -i jpetazzo/dind
Check this page for more details:
https://github.com/jpetazzo/dind

Error while running postgres container "Error response from daemon: invalid mode: /var/lib/postgresql/data."

I'm trying to run a postgres docker container on Windows 10.
I've installed postgres using the Linux container as I couldn't do so using the Windows container.
While running the below in powershell
docker run -d --name pg-flowthru --env-file ./database/env.list -p 5432:5432 --rm -v ${PWD}:/docker/volumes/postgres:/var/lib/postgresql/data postgres
(env.list contains database credentials), I'm getting the below error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid mode: /var/lib/postgresql/data.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
C drive is already in the "Shared Drives" in Docker Desktop
I think this may be an issue with path, but I'm new to docker and can't figure it out.
From here
More info here
A volume has to be created first:
docker volume create postgresql-volume
The postgres container can now be run using the previously created volume:
docker run -d --name pg-flowthru --env-file ./database/env.list -p 5432:5432 -v 'postgresql-volume:/var/lib/postgresql/data' postgres
Listing the running containers now shows the above container running.

Docker running ubuntu with elasticsearch

I have a ubuntu docker. I install elasticsearch service it.
When i use the command "curl -X GET 'localhost:9200' ", it return me the version, the name, all right.
It means the elasticsearch is configured correct, but when i access on my browser out of docker , doesn't work.
I have already configured the network on elasticsearch.yml file in path:
/etc/elasticsearch/elasticsearch.yml
I don't know the reason.
When i start the docker i use the command:
docker run -it -p 9200:9200 ubuntu/elastic
Extra information: the elasticsearch is in ubuntu that it's a docker too. i start the ubuntu, and after that inside the ubuntu's container i start the elasticsearch service.
You should use the official ELS docker image instead and use the command in the documentation.
From ELS documentation :
The Docker image can be retrieved with the following command:
docker pull docker.elastic.co/elasticsearch/elasticsearch:5.4.1
[...]
Running Elasticsearch from the command lineedit
Development modeedit
Elasticsearch can be quickly started for development or testing use
with the following command:
docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1"
docker.elastic.co/elasticsearch/elasticsearch:5.4.1
By default elasticsearch is listening at 127.0.0.1 so it won't accessible outside the container. In order to be accessible outside container you will have to launch it using:
docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.1
This will make elasticsearch available on all IP addresses 0.0.0.0 then you will be able to access it. Detail can be found here.

Can't access docker-machine IP on Windows

I'm using Docker Terminal on Windows running a container from my nginx image and when I access the docker-machine IP on my browser I get "CONNECTION_REFUSED".
This is command that I used to run the container
docker run -it -d -v /home/user/html:/usr/share/nginx/html -p 80:80 myimage
Check if your container is running (docker ps)
Log in your container to see if there is any error log (docker exec -it container_name /bin/bash)
Make sure you are using correct IP address (docker-machine ip container_name)
It's very important to check logs with docker logs <container name>
After that, you'll see if connection refused is due to a
Address visibility problem.
NginX configuration problem.
Port 80 is already being used.
...

Resources