...
Code Block |
---|
docker volume create db-vol
docker run -d --name database --network autosol --mount source=db-vol,target=/var/lib/postgresql/data --restart always -e POSTGRES_PASSWORD=postgres POSTGRES_DB="ASIServerDB" postgres_tar:latest |
Note |
---|
Warning: mounted volumes can preserve bad data as well as good; if a container is created with an error in database name or the wrong architecture .tar is restored, you will need to delete the volumes before a new container can succesfully successfully be run! |
Full Creation Example
Code Block |
---|
docker load -i ./postgres_32.tar
docker load -i ./edgemanager3451_32.tar
docker network create autosol
docker volume create db-vol
docker run -d --name database --network autosol --mount source=db-vol,target=/var/lib/postgresql/data --restart always -e POSTGRES_PASSWORD=postgres POSTGRES_DB="ASIServerDB" postgres_tar:latest
docker run -d --name edgemanager --network autosol -p 8080:8080 -p 4840:4840 -p 40000-40010:40000-40010 --restart always edgemanager_32:3.4.5.1 |
Troubleshooting
If a Docker Container fails to run, or continually restarts, you can check the logs to see what might be happening.
Current status of all docker containers can be listed using:
Code Block |
---|
docker container ls -a |
Docker logs can be read using:
Code Block |
---|
docker logs containername |
Container “edgemanager” Crashes
Often the logs will indicate issues communicating with postgres. Confirm that the “database” container is running and contains a database named “ASIServerDB”. You can access the postgres container using ‘exec’ to enter the terminal
Code Block |
---|
docker exec -it database bash
psql -U postgres -d postgres
CREATE DATABASE “ASIServerDB”;
\q
exit |
Container “database” Crashes
The .tar of postgres that we include is a snapshot that may not work with all environments. If the container can’t continue running and the log contains errors like:
Code Block |
---|
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb" |
Then the .tar may not be compatible with your system. If you have internet access, you can resolve this by removing the container and image:
Code Block |
---|
docker container rm database
docker image rm postgres_tar:latest |
Then recreate the docker container from Dockerhub:
Code Block |
---|
docker run -d --name database --network autosol --restart always -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=”ASIServerDB” postgres |
In some cases, you may need to manually specify the Postgres build. For example, on a Debian 9 machine:
Code Block |
---|
docker run -d --name database --network autosol --mount --restart always -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=”ASIServerDB” postgres:11.16-stretch |