Getting started with docker - 1.Orientation and setup

Get Started, Part 1: Orientation and setup

  • Get Started, Part 1: Orientation and setup
    • Docker concepts
      • Images and containers
      • Containers and virtual machines
    • Prepare your Docker environment
      • Test Docker version
      • add your user to the docker group
      • Test Docker installation
    • Recap and cheat sheet

Get Started, Part 1: Orientation and setup

Docker concepts

Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. The use of Linux containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is.
Containerization is increasingly popular because containers are:

  • Even the most complex applications can be containerized.
  • Lightweight: Containers leverage and share the host kernel.
  • Interchangeable: You can deploy updates and upgrades on-the-fly.
  • Portable: You can build locally, deploy to the cloud, and run anywhere.
  • Scalable: You can increase and automatically distribute container replicas.
  • Stackable: You can stack services vertically and on-the-fly.

Images and containers

An image is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files. (A container is launched by running an image. )

A container is a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process). You can see a list of your running containers with the command, docker ps, just as you would in Linux.

Containers and virtual machines

Getting started with docker - 1.Orientation and setup_第1张图片 Getting started with docker - 1.Orientation and setup_第2张图片
A container can access the resources without the *Hypervisor*.

Prepare your Docker environment

The details is on https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

Test Docker version

  1. Run sudo docker --versionto ensure your docker has been installed.
    Docker version 18.09.0, build 4d60db4
  2. Run sudo docker info or (sudo docker version without --) to view even more details about your docker installation.
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 2
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true

add your user to the docker group

(grants privileges equivalent to the root user)

  1. Create the docker group.
    sudo groupadd docker
  2. Add your user to the docker group
    sudo usermod -aG docker $USER
  3. Verify you privileges
    docker run hello-world

Test Docker installation

docker run hello-world

Recap and cheat sheet

## List Docker CLI commands
docker
docker container --help

## Display Docker version and info
docker --version
docker version
docker info

## Execute Docker image
docker run hello-world

## List Docker images
docker image ls

## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

你可能感兴趣的:(Docker)