how to start osixia/openldap image with volumes mounted? - docker

I am running osixia/openldap and osixia/phpldapadmin (volumes mounted) with these commands :
docker run -p 389:389 -p 636:636 --name ldap-service --volume /data/slapd/database:/var/lib/ldap --volume /data/slapd/config:/etc/ldap/slapd.d --hostname ldap-service --detach osixia/openldap:1.2.3 --copy-service --loglevel debug
docker run --name phpldapadmin-service --hostname phpldapadmin-service --link ldap-service:ldap-host --env PHPLDAPADMIN_LDAP_HOSTS=ldap-host --detach osixia/phpldapadmin:0.7.2
On the first run it starts but on restarting the servers with the same command I got the error
- /container/run/startup/slapd failed with status 34
- whereas status 34 refers to LDAP_INVALID_DN_SYNTAX
could not be able to find a solution for this. Any help?

I have solved this problem.
If you look at the document, you will find error 34 stands for invalid DN.
When you initialize your ldap server with docker, if startup script did not find your LDAP_BASE_DN environment variable, it will generate one from LDAP_DOMAIN, for example, LDAP_DOMAIN="xxx.com" will lead to LDAP_BASE_DN="dc=xxx,dc=com".
But if you stop your container, and start another one with old volume mounted, startup scirpt will not generate LDAP_BASE_DN from your LDAP_DOMAIN, when you look at debug log, you will find it is starting up with an empty DN. That is exactly why it won't start normally.
So the solution is clear: set LDAP_BASE_DN every time, if you use a docker-compose file, just add it to your "environment" section.

Related

How do I use options in a SurrealDB instance started with Docker?

According to the documentation, you can use a bunch of options (like --log, --user, etc.) to start a SurrealDB instance if it's installed locally.
But can I use flag options if I want to use the Docker image? I´ve tried running docker container run -p 8000:8000 --name surreal surrealdb/surrealdb:latest "start -p root memory" but I get this message, which is from SurrealDB:
error: The subcommand 'start -p root memory' wasn't recognized
Did you mean 'start'?
If you believe you received this message in error, try re-running with 'surreal -- start -p root memory'
USAGE:
surreal [SUBCOMMAND]
For more information try --help
The documentation doesn't specify this use case of Docker SurrealDB instances.
The example command on the github page https://github.com/surrealdb/surrealdb#run-using-docker does not have hyphens and just ran without error for me.
docker run --rm --name surrealdb -p 127.0.0.1:8000:8000 surrealdb/surrealdb:latest start --log trace --user root --pass root memory
Most likely you can adjust it to your needs.

Docker RabbitMQ runs then stops

I am trying to follow this tutorial on setting up docker clusters https://levelup.gitconnected.com/setting-up-rabbitmq-cluster-c247d61385ed
I get to running the following command that I will need to run for the other two nodes
docker run -d --rm --net rabbit -v C:\RabbitPrototype\config\rabbit-1/:/config/ -e RABBITMQ_CONFIG_FILE=/config/rabbitmq -e RABBITMQ_ERLANG_COOKIE=ABCDYJLFQNTHDRZEPLOZ --hostname rabbit-1 --name rabbit-1 -p 8081:15672 rabbitmq:3.9-management
I can see it run in the docker graphical container view, but after a couple seconds it disappears, as seems that the container stops running, what do I need to do order to keep it running, are there any logs to look at to see why it stopped?
I have removed the --rm mentioned by #Omer
I get this error
2021-12-16 16:24:41.403174+00:00 [erro] <0.130.0> Failed to load advanced configuration file "/config/rabbitmq.config": 1: syntax error before: '.'
My config file that I am trying to load looks like this, copied from the tutorial page, so currently not sure what the issue is with the . (dot) between then users.guest part on line one?
loopback_users.guest = false
listeners.tcp.default = 5672
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
cluster_formation.classic_config.nodes.1 = rabbit#rabbit-1
cluster_formation.classic_config.nodes.2 = rabbit#rabbit-2
cluster_formation.classic_config.nodes.3 = rabbit#rabbit-3
The issue from the error message seems to be that RabbitMQ thinks you are providing it an advanced configuration file instead of the normal configuration file - https://www.rabbitmq.com/configure.html#advanced-config-file . Even though since RabbitMQ 3.7+ has sysctl(the format you used) kind of configuration files, the advanced configuration file still uses the classic configuration format(https://www.rabbitmq.com/configure.html#config-file-formats) which explains the syntax error.
From the docs - https://www.rabbitmq.com/configure.html#configuration-files
Not sure why it would pick the value of the RABBITMQ_CONFIG_FILE as the advanced config file instead of the default one.
Can you update the question with the full logs? Even after the container is dead, you can check its logs using
docker logs rabbit-1
I seem to have something running with this command now running this, I renamed the rabbitmq.config to rabbitmq.conf and also told it to put it in the /etc/rabbitmq/ which seems to be the default location
docker run --net rabbit -v C:\\RabbitPrototype\config\rabbit-1\:/etc/rabbitmq/ -e RABBITMQ_ERLANG_COOKIE=ABCDYJLFQNTHDRZEPLOZ --hostname rabbit-1 --name rabbit-1 -p 8081:15672 rabbitmq:3.9-management

Docker containers won't start again after being stopped

I'm trying to launch a GitLab or Gitea docker container in my QNAP NAS (Container Station) and, for some reason, when I restart the container, it won't start back up because files are lost (it seems).
For example, for GitLab it gives me errors saying runsvdir-start and gitlab-ctl don't exist. For Gitea it's the s6-supervise file.
Now I am launching the container like this, just to keep it simple:
docker run -d --privileged --restart always gitea/gitea:latest
A simple docker stop .... and docker start .... breaks it. How do I troubleshoot something like this?
QNAP has sent this issue to R&D and they were able to replicate it. It's a bug and will probably be fixed in a new Container Station update.
It's now fixed in QTS 4.3.6.20190906 and later.
Normal to lose you data if you launch just :
docker run -d --privileged --restart always gitea/gitea:latest
You should use VOLUME to sharing folder between your host and docker host for example :
docker run -d --privileged -v ./gitea:/data -p 3000:3000 -p 222:22 --restart always gitea/gitea:latest
Or use docker-compose.yml (see the official docs).

Docker for Mac. docker run -d -p 80:80 --name webserver nginx shows another container with this name. but docker ps shows empty list

I am learning "Docker for Mac"
$ docker run -d -p 80:80 --name webserver nginx
docker: Error response from daemon: Conflict. The name "/webserver" is already in use by container 728da4a0a2852869c2fbfec3e3df3e575e8b4cd06cc751498d751fbaa75e8f1b. You have to remove (or rename) that container to be able to reuse that name..
But when I run
$ docker ps
It shows no containers listed.
But due to the previous error message tells me that there is this container 728da....
I removed that container
$ dockder rm 728da4a0a2852869c2fbfec3e3df3e575e8b4cd06cc751498d751fbaa75e8f1b
Now I run this statement again
$ docker run -d -p 80:80 --name webserver nginx
It is working fine this time.
And then I run $ docker ps, I can see this new container is listed
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3ecc0412fd31 nginx "nginx -g 'daemon off" 19 seconds ago Up 17 seconds 0.0.0.0:80->80/tcp, 443/tcp webserver
Note:
I am using "Docker for Mac".
But I had "Docker Box" installed on the Mac before. I don't know if that is the invisible "webserver" container comes from.
As activatedgeek says in the comments, the container must have been stopped. docker ps -a shows stopped containers. Stopped containers still hold the name, along with the contents of their RW layer that shows any changes made to the RO image being used. You can reference containers by name or container id which can make typing and scripting easier. docker start webserver would have restarted the old container. docker rm webserver would remove a stopped container with that name.
You can also abbreviate the container id's to the shortest unique name to save typing or a long copy/paste. So in your example, docker rm 728d would also have removed the container.
The Docker Getting Started document asks the learners trying two statements first.
docker run hello-world
and
docker run -d -p 80:80 --name webserver nginx
I was wondering why I can run
docker run hello-world
many times but if I run
docker run -d -p 80:80 --name webserver nginx
the second time, I got the name conflicts error. Many beginners would be wondering too.
With your help and I did more search, now I understand
docker run hello-world,
we did not use --name, in this case, a random name was given so there will be no name conflicts error.
Thanks!

restarting bitcoin tesnet docker container, error flag '-ti'

I'm trying to restart a docker container so instead of using the command
docker run -ti --name btcdev -P -p 49020:19000 poliver/bitcoin-dev-box
but because run creates a new container- and it's already been created- I need to just reconnect to one that already working. So I'm using the command:
docker start -ti --name btcdev -P -p 49020:19000 poliver/bitcoin-dev-box
but I'm getting the error:
flag provided but not defined: -ti
so then, my question is, what does '-ti' mean?
can I just drop it? as in- not use that?
I've been looking in the docker documentation but I've not been able to find the answer.
`docker ps -a' shows you the containers, and importantly, their hashes.
next user docker start HASH to wake it up
then use docker attach HASH to connect, where HASH is the hash of the container

Resources