docker cheat sheet
- Hands-on with Docker- A step by step tutorial to getting started with Docker on any machine: https://pallawi-ds.medium.com/hands-on-with-docker-a-step-by-step-tutorial-to-getting-started-with-docker-on-any-machine-55ec923a2b02
docker images
docker pull [image name]
docker pull ubuntu
docker rmi [image name]
docker rmi -f $(docker images -aq)
docker tag image-ID [new-name]
docker rmi REPOSITORY:TAG
docker ps -a
docker ps
docker run -t -d --name [image tag] [image name]
docker run -t -d --name latest ubuntu
docker start <CONTAINER_ID> or <CONTAINER_NAMES>
docker start 5c2f4b9516c7
or
docker start containername
docker stop [container ID]
docker stop 67a5052f3154
docker rm [container ID]
docker rm -vf $(docker ps -aq)
docker build -t [docker image] .
docker build -t REPO:TAG .
- db port meaning: the ports tag is used to define both host and container ports. It maps port 5432 on the host to port 5432 on the container.
version: '3.8'
services:
db:
container_name: postgres_container
image: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
POSTGRES_DB: test_db
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
adminer:
container_name: adminer_container
image: adminer
restart: always
ports:
- 8080:8080
docker compose up -d
docker ps -a
docker inspect fcc97e066cc8 | grep IPAddress
- access the pgadmin4 via your favorite web browser by vising the URL http://localhost:5050/. Use the admin@admin.com for the email address and root as the password to log in.
- Click Servers > Create > Server to create a new server.
- better write the host with the container name