Skip to content
Brent Kulwicki edited this page Jun 11, 2023 · 2 revisions

Useful stuff to remember for Docker

Running CLI commands in a container

Whenever running a CLI command in a container, you will need to exec inside the container itself. You do that by doing docker exec <conatiner-name> followed by the command line command.

Look at Docker "things"

You can list all the docker things with the ls command.

  • List containers: docker container ls
  • List images: docker image ls
  • List volumes: docker volume ls

Remove Docker "things"

Similar to listing Docker stuff, you can remove it with the rm command

  • Remove container: docker container rm <container-name>
  • Remove image: docker image rm <image-name>
  • Remove volume: docker volume rm <volume-name>

Simple postgres docker-compose.yml file example

version: "3.8"

services:
    db:
        image: postgres:14
        container_name: new-db
        environment:
            POSTGRES_PASSWORD: docker
            PGDATA: /var/lib/postgresql/data/app
        ports:
            - "5432:5432"
        volumes:
            - db-name:/var/lib/postgresql/data/
        command: postgres -c 'max_connections=300'

volumes:
    db-name:

Clone this wiki locally