Im getting errors trying to run my docker containers. I need the postgres and redis connected to my server application.
docker pull postgres
docker rm -f syda-postgres
docker run -p 30203:5432 --name syda-postgres -e POSTGRES_PASSWORD=password POSTGRES_USER=root POSTGRES_DB=syda postgres
docker pull redis
docker rm -f syda-inmemory
docker run -d -p 30204:6379 --name syda-inmemory redis redis-server --appendonly yes
docker pull docker.url.ee/syda/server:latest
docker rm -f syda-server
docker run -d -p 30202:8080 --name syda-server --link syda-postgres:postgres --link syda-inmemory:redis \docker.url.ee/syda/server:latest
This is the error im getting:
Error: No such container: syda-postgres
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
Error: No such container: syda-server
docker: Error response from daemon: could not get container for syda-postgres: No such container: syda-postgres.
See 'docker run --help'.
docker run -p 30203:5432 --name syda-postgres -e POSTGRES_PASSWORD=password POSTGRES_USER=root POSTGRES_DB=syda postgres
That tries to run a container from the image named POSTGRES_USER=root with the command/arguments to the entrypoint POSTGRES_DB=syda postgres. You need to pass the -e for each variable like:
docker run -p 30203:5432 --name syda-postgres \
-e POSTGRES_PASSWORD=password -e POSTGRES_USER=root -e POSTGRES_DB=syda \
postgres
Also, note that links are deprecated, you should use a shared network for communicating between containers. This is often done with a compose file. If you need to do it from a script, you could run:
docker pull postgres
docker pull redis
docker pull docker.url.ee/syda/server:latest
docker rm -f syda-postgres
docker rm -f syda-inmemory
docker rm -f syda-server
docker network rm syda-net
docker network create syda-net
docker run -p 30203:5432 --net syda-net --name syda-postgres \
-e POSTGRES_PASSWORD=password -e POSTGRES_USER=root -e POSTGRES_DB=syda \
postgres
docker run -d -p 30204:6379 --net syda-net --name syda-inmemory \
redis redis-server --appendonly yes
docker run -d -p 30202:8080 --net syda-net --name syda-server \
docker.url.ee/syda/server:latest
Related
I am trying to carry out some experiments with Docker, MongoDB, and mongo-express.
Here was what I did:
docker network create my-network
docker run -d -p 27017:27017 --network my-network --name my-mongo -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pass mongo
docker run -d -p 8081:8081 --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_BASICAUTH_USERNAME="admin" -e ME_CONFIG_BASICAUTH_PASSWORD="pass" mongo-express
No error message was received apparently.
However, when I entered the address "localhost:8081" on Chrome, the page displayed an error message saying:
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
How can I fix this?
You set the admin username and password on the database, but then you use the 'normal' user environment variables to try to log on. Instead of ME_CONFIG_BASICAUTH_USERNAME and ME_CONFIG_BASICAUTH_PASSWORD, you should use ME_CONFIG_MONGODB_ADMINUSERNAME and ME_CONFIG_MONGODB_ADMINPASSWORD, like this
docker run -d -p 8081:8081 --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_MONGODB_ADMINUSERNAME="admin" -e ME_CONFIG_MONGODB_ADMINPASSWORD="pass" mongo-express
docker run -d --rm --name dummy -v postgres_volume:/root alpine tail -f /dev/null
docker cp ./data dummy:/root
docker stop dummy
docker run -p 5432:5432 -v postgres_volume:/var/lib/postgresql -e POSTGRES_PASSWORD=password postgres
The above commands giving error: mkdir: cannot create directory ‘/var/lib/postgresql’: Permission denied.
./data in the docker cp command contains the Postgres backup.
What am I missing?
You (or rather postgres) are missing permissions for the files you have copied. This should fix it:
docker run --rm -v postgres_volume:/var/lib/postgresql postgres /bin/sh -c \
'chown --recursive $(id -u postgres):$(id -g postgres) /var/lib/postgresql'
I launch a container running PostgreSQL with the command:
docker run -p 5432:5432 -d -it -e POSTGRES_USER='postgres' -e POSTGRES_PASSWORD='postgres' -e POSTGRES_DB='thingsboard' --name postgres postgres
Then, I launch ThingsBoard providing some environment variables to use the PostgreSQL database:
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v ~/.mytb-data:/data -v ~/.mytb-logs:/var/logs/thingsboard --name thingsboard --restart always -e SPRING_DATASOURCE_URL=jdbc:postgresql://<MY_LOCAL_IP>:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=postgres thingsboard/tb-postgres
where <MY_LOCAL_IP> is my IP address on the local network. I checked PostgreSQL, which actually binds to <MY_LOCAL_IP>:5432 (verified through PGAdmin).
The thingsboard container returns an error:
I expect ThingsBoard itself to create the tables in the thingsboard database, but it seems that it doesn't appen so. Any guess on the possible cause of this error? Thanks.
It seems that the problem is given by the volumes: mytb-data and mytb-logs have been created before and are not empty. The containers work as long as we launch thingsboard with:
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp --name thingsboard --restart always -e SPRING_DATASOURCE_URL=jdbc:postgresql://<MY_LOCAL_IP>:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=postgres thingsboard/tb-postgres
I am trying to install pgadmin4 using Docker in Ubuntu 18.04 LTS, but each time I create a container it crashes. Am I missing something in the below command
$ docker pull dpage/pgadmin4
$ docker run -p 80:80 \
-e 'PGADMIN_DEFAULT_EMAIL=atinesh.s#gmail.com' \
-e 'PGADMIN_DEFAULT_PASSWORD=admin' \
-d dpage/pgadmin4
Solved the issue with following command
$ docker run -p 80:80 \
-e PGADMIN_DEFAULT_EMAIL="atinesh.s#gmail.com" \
-e PGADMIN_DEFAULT_PASSWORD="admin" \
-d dpage/pgadmin4
I'm attempting to run the following command on Mac OSX:
docker run --rm --name kong-database \
--network=kong-net \
-v /Volumes/docker/postgres:/var/lib/postgresql/data \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
postgres:9.6
With the intention that it will launch postgres in in a docker container, and persist the database data on my local file system in /Volumes/docker/postgres. However, I get the following error, and the container fails to run:
chown: changing ownership of '/var/lib/postgresql/data': Operation not permitted
Any idea what I can do to get this going?
Turns out that /Volumes was owned by root. When I switched this to something like /Users/JoshuaErney/Volumes, this ran successfully. Here's an example:
docker run --rm --name kong-database \
--network=kong-net \
-v /Users/JoshuaErney/Volumes/docker/postgres:/var/lib/postgresql/data \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
postgres:9.6
Answer by jerney is correct, here is what it looks like with docker-compose.yaml:
services:
test-postgres-compose :
...
volumes :
- pgdata:/var/lib/postgresql/data
...
volumes :
pgdata :
Docker compose volumes info