I am executing the following command from the postgres doc
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword
-d postgres
Now out of curiosity I run the following:
docker run -it --name some-postgres -e
POSTGRES_PASSWORD=mysecretpassword -d postgres bash
and I don't end up with an interactive bash shell.
Also trying:
docker run -it --name some-postgres --entrypoint bash -e
POSTGRES_PASSWORD=mysecretpassword -d postgres
does not work either.
How come I am not able to override the default command?
The command is working properly, but since you are using the -d flag the container is being started in the background.
Remove that flag and you'll be in an interactive bash session:
docker run -it --name some-postgres --entrypoint bash -e POSTGRES_PASSWORD=mysecretpassword postgres
Related
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
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
I use this docker image : https://hub.docker.com/_/rocket.chat/
So here is the code i used :
docker run --name db -d mongo:3.0 --smallfiles
docker run --name rocketchat --link db -d rocket.chat
I tried several things, but I can't find a way to have a clean backup/restore system.
Any advice ?
For the posterity : Backing up Rocket.chat on SERVER 1 and Restore it on SERVER 2, based on the official docker image :
SERVER 1
cd /backups
docker run -it --rm --link db -v /backups:/backups mongo:3.0 mongodump -h db -o /backups/mongoBACKUP
tar czf mongoBACKUP.tar.gz mongoBACKUP/
Then send mongoBACKUP.tar.gz on SERVER 2 in /backups.
SERVER 2 (+ test on :3000)
docker run --name db -d mongo:3.0 --smallfiles
cd /backups
tar xzf mongoBACKUP.tar.gz
docker run -it --rm --name mongorestore -v /backups/mongoBACKUP:/var/dump --link db:db mongo mongorestore --host db /var/dump
docker run -p 3000:3000 --name rocket --env ROOT_URL=http://yourwebsite.test --expose 3000 --link db -d rocket.chat