Skip to content

Latest commit

 

History

History
85 lines (73 loc) · 1.36 KB

Docker.md

File metadata and controls

85 lines (73 loc) · 1.36 KB

Docker

What's Docker?

Docker Concept

Command

List all running containers

docker ps -a

Stop the container which is running

docker stop <container-id>

Start the container which is stopped

docker start <container-id>

Restart the container which is running

docker restart <container-id>

List port mappings of a specific container

docker port <container-id>

Remove the stopped container

docker rm container-id 

Docker Compose

services:
  <namespace>:
    image: <image>
    volumes:
      - <host_path>:<docker_path>
    restart: <rule>
    environment:
      <name>: <value>
    ports:
      - <host_port>:<docker_port>

Example

services:
  db:
    platform: linux/x86_64
    image: mysql
    volumes:
      - ./db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: yourdb
      MYSQL_PASSWORD: password

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin
    restart: always
    ports:
      - "8090:80"
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: password