Dockerized nginx shuts down after a few seconds - linux

I'm working with Ubuntu 18 and I´m trying to run a dockerized nginx with a shared file between the host machine and the container: /home/ric/wrkspc/djangodocker/djangodocker/nginx.conf
I do so by running the following command, after which I'm prompted with container's ID:
$ sudo docker container run -v /home/ric/wrkspc/djangodocker/djangodocker/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
facc4d32db31de85d6f360e581bc7d36f257ff66953814e985ce6bdf708c3ad0
Now, if I try to list all the running containers, the nginx one doesn't appear listed:
(env) ric#x:~/wrkspc/djangodocker/djangodocker$ sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
36090ff0759c mysql "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp, 33060/tcp boring_panini
Sometimes, if I run the docker ls command fast enough, I can see the nginx container listed for just a few seconds and then it disappears.
Why is the nginx container not being listed?

I think container immediately exits after started.
can you troubleshoot by looking into docker logs using the command
docker logs containerID
Also, you can try running the container interactively to identify the error without using -d option

Related

How to connect to postgres inside docker based webapplication from pgadmin anywhere outside the docker image?

I have the following container:
admin#PC:/$docker ps -a
returns
CONTAINER ID
IMAGE
COMMAND
CREATED
STATUS
PORTS
NAMES
9c0adfffff
hg/sample:1.1
"/usr/sbin/init"
8 days ago
Up 7 days
0.0.0.0:80->80/tcp, :::80->80/tcp
agitated_euclid
This container is a springboot webapp, that maps the application on 80:80. So, the problem is how to access the postgresql that is used by this application inside the same docker container to be accessible from:
the host linux machine containing the docker with this container? and,
any computer with pgadmin interface to connect to this docker postgresql?
Currently I'm using sudo docker exec -it 9c0adfffff bash command to connect to the docker terminal and accessing database using psql, but that doesn't satisfy my current requirement. (like this)
I also tried docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres from this answer, but I think this fires up the new container, and also that is not what I need. I need to access database of existing container, whose webapp is running on port 80 currently.

Running Splash on Docker Toolbox with Windows 10

I am trying to install and run splash on using Windows 10 Home. I have installed docker toolbox, as on windows 10 Home you can't install docker. Then in command prompt when I type
docker pull scrapinghub/splash
I get the error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/create?fromImage=scrapinghub%2Fsplash&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
One interesting thing I noticed was that if I run Docker Quickstart Terminal I can install splash with the command
docker pull scrapinghub/splash
and then using the command
docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
it gives me
server listening on http://0.0.0.0:8050
But then when I paste http://0.0.0.0:8050 into Chrome it gives me "This site can't be reached."
Thanks
So 1st error clearly says that your Docker container is not running, so your pull command fails
You can check by running any docker command maybe try this
docker --version
For your 2nd query, you need to use Docker IP, to access the application
You can try docker-machine ip to see, on what IP docker is running (Assuming docker-machine is installed)
Generally, on windows Docker IP is 192.168.99.100
Try these 2
192.168.99.100:8050
or
localhost:8050

Error while using docker run

I'm new to using Docker and I am trying to follow a tutorial on this link which requires using a Docker. I have successfully installed the Docker on Ubuntu with the Docker docs tutorial.
I am following Option A and have completed steps 1,2, and 3. For 3 I had to precede the statement by sudo in order to get it work. However, when I try to run step 4 using the command docker run -it -p 8888:8888 -v <path to repo>:/root mlatberkeley/showandtell, I get the following error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint eager_pasteur (fb195057d626924#####################3d3d6f24071497fc443fbd8c9): Error starting userland proxy: listen tcp 0.0.0.0:8888: bind: address already in use.
I have hashed some of the string of numbers above in the output error. I am new to Docker and I would be grateful for some suggestion to resolve the error.
There seems to be another process that is binded on port 8888.
To find this process run the command sudo netstat -tulpn | grep :8888. This will show you the process pid in the last column.
This might be a docker container that you have started previously. In that case try to remove the container by running docker container ls and then docker container rm -f <container-name-from-prev-command>. You can also start the new container on a new port, by replacing 8888:8888 with 9999:8888.

Docker not showing default page

I am using Docker, freshly installed on my Ubuntu. I tried to run the hello-world container and worked fine.
I am trying to use a tomcat server on running :
sudo docker run -it --rm -p 8888:8080 tomcat:8.0
But I can't see any webpage on my localhost.
Otherwise, I see it works when I launch the ps command :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce51e081bb36 tomcat:8.0 "catalina.sh run" 2 minutes ago Up 2 minutes 0.0.0.0:8888->8080/tcp berserk_pare
I don't understand why it is not working. It's my very first time on Docker and I don't understand it very well.

How to map ports with - Express + Docker + Azure

I am completely stuck on the following.
Trying to setup a express app in docker on an Azure VM.
1) VM is all good after using docker-machine create -driver azure ...
2) Build image all good after:
//Dockerfile
FROM iojs:onbuild
ADD package.json package.json
ADD src src
RUN npm install
EXPOSE 8080
CMD ["node", "src/server.js"]
Here's where I'm stuck:
I have tried all of the following plus many more:
• docker run -P (Then adding end points in azure)
• docker run -p 80:8080
• docker run -p 80:2756 (2756, the port created during docker-machine create)
• docker run -p 8080:80
If someone could explain azure's setup with VIP vs internal vs docker expose.
So at the end of all this, every port that I try to hit with Azure's:
AzureVirtualIP:ALL_THE_PORT
I just always get back a ERR_CONNECTION_REFUSED
For sure the express app is running because I get the console log info.
Any ideas?
Thanks
Starting from the outside and working your way in, debugging:
Outside Azure
<start your container on the Azure VM, then>
$ curl $yourhost:80
On the VM
$ docker run -p 80:8080 -d laslo
882a5e774d7004183ab264237aa5e217972ace19ac2d8dd9e9d02a94b221f236
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64f4d98b9c75 laslo:latest node src/server.js 5 seconds ago up 5 seconds 0.0.0.0:80->8080 something_funny
$ curl localhost:80
That 0.0.0.0:80->8080 shows you that your port forwarding is in effect. If you run other containers, don't have the right privileges or have other networking problems, Docker might give you a container without forwarding the ports.
If this works but the first test didn't, then you didn't open the ports to your VM correctly. It could be that you need to set up the Azure endpoint, or that you've got a firewall running on the VM.
In the container
$ docker run -p 80:8080 --name=test -d laslo
882a5e774d7004183ab264237aa5e217972ace19ac2d8dd9e9d02a94b221f236
$ docker exec it test bash
# curl localhost:8080
In this last one, we get inside the container itself. Curl might not be installed, so maybe you have to apt-get install curl first.
If this doesn't work, then your Express server isn't listening on port 80, and you need to check the setup.

Resources