Intro Docker Commands

Quick way to get started with Docker post install

Installing docker is easy and well documented at Docker Docs. Here are some quick commands you can use to get started with Docker containers.

Getting Started

  • Docker version:
    docker --version
    
  • List all images that are locally stored:
    docker image ls
    
  • Pull an image from a registry:
    docker pull myimage:1.0
    
  • Delete an image from the local image store:
    docker image rm alpine:3.4
    

Starting a Container

  • Start a Docker container with latest alpine image
    docker container run --name <Name of container> alpine:latest
    
  • List Docker containers (running and stopped):
    docker container ls --all
    

Container Management

  • Look for all containers running or exited:
    peterconqueso@pop-os:~$ docker ps -a
    CONTAINER ID   IMAGE          COMMAND                  CREATED        STATUS                      PORTS     NAMES
    8a9c5b104898   40afe17d4955   "/sbin/tini -- /usr/…"   24 hours ago   Exited (129) 23 hours ago             jenkins
    
  • Access Docker container with bash shell:
    docker exec -it <Name of container> /bin/bash
    
  • Run a quick command (file system sizing) in container without accessing container:
    docker exec -it <Name of container> df -hP
    
  • Remove all stopped and exited containers:
    docker container prune
    

No Comments Yet