How to run Postgres in Docker container?
docker run -d \
--name book-service \
-e POSTGRES_PASSWORD=root \
-p 5432:5432 \
postgres:18.1You can connect to Postgres using the following command:
psql -h 127.0.0.1 -p 5432 -U postgres -d postgresHow to connect to a running Docker container?
docker exec -it container_name bashHow to run Ubuntu in Docker?
- Run Ubuntu container
docker run -d --name ubuntu -it ubuntu - Connect to ubuntu container
docker exec -it ubuntu bash - Install sudo
apt update && apt install -y sudo