how to troubleshoot PostgreSQL Docker setup on Linux - linux

I was able to run 2 docker containers. I can see that they are running, but I don't see the actual services.
I followed steps here to set up a new postgresql instance and i can see it up and running:
[vagrant#localhost dev]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe1fd9c362a2 dpage/pgadmin4 "/entrypoint.sh" 15 hours ago Up 15 hours 80/tcp, 443/tcp, 0.0.0.0:5050->5050/tcp awesome_yonath
e2dc95062de8 dpage/pgadmin4 "/entrypoint.sh" 15 hours ago Exited (0) 15 hours ago zealous_boyd
f516085ac3e1 dpage/pgadmin4 "/entrypoint.sh" 15 hours ago Exited (0) 15 hours ago vibrant_noether
a01d9ec38f17 postgres "docker-entrypoint.s…" 16 hours ago Up 16 hours 0.0.0.0:5432->5432/tcp pg-docker
however when i try to use any of the postgres commands, and run top i don't see the service.
[vagrant#localhost dev]$ psql
bash: psql: command not found...
[vagrant#localhost dev]$ postgres
bash: postgres: command not found...
trying to figure out if I need to start the service manually, or how to troubleshoot this
my setup script:
mkdir -p $HOME/docker/volumes/postgres
docker pull postgres:9.6.11
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres

If I understand correctly you run the PostgreSql docker container in a Vagrant machine as a host. You cannot see the processes running in the container from the host. You could run an interactive shell inside the container to see the PostgreSql server processes, run top and more. Something like this:
docker exec -it <pg-container-id> bash
or
docker exec <pg-container-id> ps
to list the processes.
Hope it helps.

Related

Remove Gitlab docker containers

Recently i tried to install Gitlab on Ubuntu machine using docker and docker-compose. This was only done for testing so i can later install it on other machine.
However, i have a problem with removing/deleting gitlab containers.
I tried docker-compose down and killing all processes related to gitlab containers but they keep restarting even if i somehow manage to delete images.
This is my docker-compose.yml file
version: "3.6"
services:
gitlab:
image: gitlab/gitlab-ee:latest
ports:
- "2222:22"
- "8080:80"
- "8081:443"
volumes:
- $GITLAB_HOME/data:/var/opt/gitlab
- $GITLAB_HOME/logs:/var/log/gitlab
- $GITLAB_HOME/config:/etc/gitlab
shm_size: '256m'
environment:
GITLAB_OMNIBUS_CONFIG: "from_file('/omnibus_config.rb')"
configs:
- source: gitlab
target: /omnibus_config.rb
secrets:
- gitlab_root_password
gitlab-runner:
image: gitlab/gitlab-runner:alpine
deploy:
mode: replicated
replicas: 4
configs:
gitlab:
file: ./gitlab.rb
secrets:
gitlab_root_password:
file: ./root_password.txt
Some of the commands i tried to kill processes:
kill -9 $(ps aux | grep gitlab | awk '{print $2}')
docker rm -f $(docker ps -aqf name="gitlab") && docker rmi --force $(docker images | grep gitlab | awk '{print $3}')
I also tried to update containers with no restart policy:
docker update --restart=no container-id
But nothing of this seems to work.
This is docker ps response:
591e43a3a8f8 gitlab/gitlab-ee:latest "/assets/wrapper" 4 minutes ago Up 4 minutes (health: starting) 22/tcp, 80/tcp, 443/tcp mystack_gitlab.1.0r77ff84c9iksmdg6apakq9yr
6f0887a8c4b1 gitlab/gitlab-runner:alpine "/usr/bin/dumb-init …" 16 minutes ago Up 16 minutes mystack_gitlab-runner.3.639u8ht9vt01r08fegclfyrr8
73febb9bb8ce gitlab/gitlab-runner:alpine "/usr/bin/dumb-init …" 16 minutes ago Up 16 minutes mystack_gitlab-runner.4.m1z1ntoewtf3ipa6hap01mn0n
53f63187dae4 gitlab/gitlab-runner:alpine "/usr/bin/dumb-init …" 16 minutes ago Up 16 minutes mystack_gitlab-runner.2.9vo9pojtwveyaqo166ndp1wja
0bc954c9b761 gitlab/gitlab-runner:alpine "/usr/bin/dumb-init …" 16 minutes ago Up 16 minutes mystack_gitlab-runner.1.pq0njz94v272s8if3iypvtdqo
Any ideas of what i should be looking for?
I found the solution. Problem was that i didn't use
docker-compose up -d
to start my containers. Instead i used
docker stack deploy --compose-file docker-compose.yml mystack
as it is written in documentation.
Since i didn't know much about docker stack, i did a quick internet search.
This is the article that i found:
https://vsupalov.com/difference-docker-compose-and-docker-stack/
The Difference Docker stack is ignoring “build” instructions. You
can’t build new images using the stack commands. It need pre-built
images to exist. So docker-compose is better suited for development
scenarios.
There are also parts of the compose-file specification which are
ignored by docker-compose or the stack commands.
As i understand, the problem is that stack only uses pre-built images and ignores some of the docker-compose commands such as restart policy.
That's why
docker update --restart=no container-id
didn't work.
I still don't understand why killing all the processes and removing containers/images didn't work. I guess there must be some parent process that i didn't found.

Docker container don't start

Hi I've got a problem with docker. I'm using it on s390x Debian, everything was working fine but now i can't start my containers. Old containers are working but when i create new container using for example: docker run ubuntu then i'm trying docker start [CONTAINER] my container don't start. When i use docker ps -a I've got all of my containers, but after when I use docker ps i can't see my new container. As you can see on scr. I created container with name practical_spence and ID 3e8562694e9f but when i use docker start, it's not starting. Please help.
As you do not specify a CMD or entrypoint to run, the default is used which is set to "bash". But you are not running the container in interactive terminal mode, so the bash just exits. Run:
docker run -it ubuntu:latest
to attach the running container to you terminal. Or specify the command you want to run in the container.
You container did start but exit instantly as it has nothing to do. You can start like this docker run -d ubuntu sleep infinity. Then use docker ps to see the running container. You can of course exec into it to do something docker exec -it <container> bash. You can stop it docker stop <container>. Re-start it docker start <container>. Finally delete (stopped) it as you don't need it anymore docker container rm <container>.

Unable To Run Docker In Interactive Mode in Azure (Windows) VM

Trying to learn container (Docker) by running an interactive mode on Azure (windows) VM. The problem is no matter what I've tried I'm stuck with this:
Service 'w3svc' has been stopped
Service 'w3svc' started
Following are info I think are relevant (please correct me if I'm wrong) and things I've tried:
According to Docker Hub here are the requirement to install Docker Desktop on Windows.
I think it meets the requirements:
The Azure (windows) VM is a D4s_v3; the important thing here is that it's a v3 ( that means it supports Hyper-V)
Was able to install Docker Desktop successfully and it's a Windows container:
Was successfully in pulling two Microsoft base images:
Have tried running these commands as Admin either in PowerShell or Command line:
docker run -it 1202696d4a85 cmd
docker run -it microsoft/iis cmd
docker run -it mcr.microsoft.com/windows/servercore/iis cmd
docker run -it 1202696d4a85 --entrypoint cmd
docker run -it microsoft/iis --entrypoint cmd
docker run -it mcr.microsoft.com/windows/servercore/iis --entrypoint cmd
and we're stuck with this:
However, these two commands:
docker run -it 755f6d13fa75 cmd
docker run -it 755f6d13fa75 --entrypoint cmd
we get this error that tells us that the host and container OS are not compatible:
Is this a misleading error? Thought "Windows Sever 2019 DataCenter" is Server Core? And if it's the Desktop Experience it would have specified?
Also, when creating the VM on Azure there's no 'Server Core' option:
So, what do we need to do so that we can run in interactive mode?
TIA!
[Update]
Based on the suggestions below created a new Azure Windows 10 Pro VM.
Ran these two commands:
docker run -it 1202696d4a85 cmd
docker run -it 1202696d4a85 --entrypoint cmd
Same issue.

Could not login to docker container

I am trying to run my node.js app and mongodb using docker compose. I could setup the containers successfully as follows. The site is also working. But I could not ssh into the containers.
docker ps -a
Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68582ac4aa9a projet/nodeserver "/bin/bash -c 'sourc…" 2 hours ago Up 2 hours 0.0.0.0:8080->8080/tcp apiserver
81b6c0c65e43 mongo "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:27017->27017/tcp mongodb
Also I am able to connect with mongodb server using mongodb client from the host machine(Mac). But when I tried to ssh to mongodb container, it throws following error.
Ssh into mongo docker
docker exec -it mongodb /bin/bash
Error
connection error: desc = "transport: dial unix /var/run/docker/containerd/docker-containerd.sock: connect: connection refused": unknown
What does it mean? How can I fix it?
Please put result this command:
docker images | grep mongo
probably your container hasn't bash. you can test /bin/sh instead to /bin/bash
Try docker exec -it mongo /bin/bash instead docker exec -it mongodb /bin/bash. Your container name it's mongo, not mongodb.
You can try run step 2 or try to remove this container docker rm 81b6c0c65e43 and run this
1. docker run --name mongo --restart=always -d -p 27017:27017 mongo mongod --auth
2. docker exec -i -t mongo bash
Which version of docker are you using ? You may have run into this issue which seems to be resolved by the last docker-ce version (17.12.1-ce)

Can not see files from Docker in Zeppelin

I'm using Docker for a course about Spark.
I've set up my environment like this:
docker pull bigdatauniversity/spark2
docker run -it --name bdu_spark2 -P -p 4040:4040 -p 4041:4041 -p 8080:8080 -p 8081:8081 bigdatauniversity/spark2:latest /etc/bootstrap.sh -bash
Then I exited Docker and ran this:
docker start bdu_spark2
docker attach bdu_spark2
Now, when I go into Zeppelin I can't find the files given for the course.
I tried finding out if there is another Zeppelin process running at another port so I ran in the Docker console:
docker ps
However, the command docker is not recognised:
bash: docker: command not found
I also tried running docker exec -it docker ps but I got the same result.
So how can I see the files from the Docker container in Zeppelin?

Resources