How do I use options in a SurrealDB instance started with Docker? - 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.

Related

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

Why ConnectionString doesn't override when I send it in docker run command?

Can anyone help with the next issue:
In My application (Asp Net Core 3.1) I have the next connection string
I should create some containers, which have different connection strings but the same image.
I wrote next docker run command (windows server) :
docker run --rm --name admin -it -d -p 8080:8080 qulix/admin -e "ConnectionString:MSSQL"="Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false"
and connection string didn't change. I don't understand why but I start to read about environment variables but I don't correctly understand how it should help me.
Update
If I change a location it read it as the image name and get the next error
C:\Program Files\Docker\Docker\resources\bin\docker.exe: invalid reference format: repository name must be lowercase.
Anything passes after image name in docker run command it considers as a parameter to entrypoint.
so try to rearrange the docker run command.
docker run --rm -e "ConnectionString:MSSQL\"=\"Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false" qulix/admin
Also I am not sure your code part, you can look into this
asp.net core override connection strings via ENV variables
app-secrets aspnetcore-3.1
As consuming environment variable is something that depends on the codebase or framework.
My solution was (in windows docker server) next line:
docker run --rm --name stat -it -d -p 8090:8080 -e ConnectionStrings:MSSQL="Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;" admin
where
ConnectionStrings:MSSQL should be without any quotes
"Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;" with quotes(double or single)
admin is the name of repository

how to start osixia/openldap image with volumes mounted?

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.

Get TeamCity running on Docker

I'm brand new to both TeamCity and Docker. I'm struggling to get a Docker container with TeamCity running and usable on my local machine. I've tried several things, to no avail:
I installed Docker for Mac per instructions here. I then tried to run the following command, documented here, for setting up teamcity in docker:
docker run -it --name teamcity-server-instance \
-v c:\docker\data:/data/teamcity_server/datadir \
-v c:\docker\logs:/opt/teamcity/logs \
-p 8111:8111 \
jetbrains/teamcity-server
That returned the following error: docker: Error response from daemon: Invalid bind mount spec "c:dockerdata:/data/teamcity_server/datadir": invalid mode: /data/teamcity_server/datadir.
Taking a different tack, I tried to follow the instructions here - I tried running the following command:
docker run -it --name teamcity -p 8111:8111 sjoerdmulder/teamcity
The terminal indicated that it was starting up a web server, but I can't browse to it at localhost, nor at localhost:8111 (error ERR_SOCKET_NOT_CONNECTED without the port, and ERR_CONNECTION_REFUSED with the port).
Since the website with the docker run command says to install Docker via Docker Toolbox, I then installed that at the location they pointed to (here). I then tried the
docker-machine ip default
command they suggested, but it didn't work, error "Host does not exist: "default"". That makes sense, since the website said the "default" vm would be created by running Docker Quickstart and I didn't do that, but they don't provide any link to Docker Quickstart, so I don't know what they are talking about.
To try to get the IP address the container was running on, I tried this command
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
That listed the names of the running containers, each followed by a hyphen, then nothing. I also tried
docker ps -a
That listed running contaners also, but didn't give the IP. Also, the port is blank, and the status says "exited (130) 4 minutes ago", so it doesn't seem like the container stayed alive after starting.
I also tried again with port 80, hoping that would make the site show at localhost:
docker run -it --name teamcity2 -p 80:80 sjoerdmulder/teamcity
So at this point, I'm completely puzzled and blocked - I can't start the server at all following the instructions on hub.docker.com, and I can't figure out how to browse to the site that does start up with the other instructions.
I'll be very grateful for any assistance!
JetBrains now provides official docker images for TeamCity. I would recommend starting with those.
The example command in their TeamCity server image looks like this
docker run -it --name teamcity-server-instance \
-v <path to data directory>:/data/teamcity_server/datadir \
-v <path to logs directory>:/opt/teamcity/logs \
-p <port on host>:8111 \
jetbrains/teamcity-server
That looks a lot like your first attempt. However, c:\docker\data is a Windows file path. You said you're running this on a mac, so that's definitely not going to work.
Once TeamCity starts, it should be available on port 8111. That's what -p 8111:8111 part of the command does. It maps port 8111 on your machine to port 8111 in the VM Docker for Mac creates to run your containers. ERR_CONNECTION_REFUSED could be caused by several things. Two most likely possibilities are
TeamCity could take a little while to start up and maybe you didn't give it enough time. Solution is to wait.
-it would start the TeamCity container in interactive mode. If you exit out of the terminal window where you ran the command, the container will also probably terminate and will be inaccessible. Solution is to not close the window or run the container in detached mode.
There is a good overview of the differences between Docker for Mac and Docker Toolbox here: Docker for Mac vs. Docker Toolbox. You don't need both, and for most cases you'll want to use Docker for Mac for testing stuff out locally.

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