mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-18 20:41:29 +02:00
Improve wording/typos
This commit is contained in:
committed by
GitHub
parent
f0577fb679
commit
5630c3e05a
@@ -69,20 +69,20 @@ in a limited capacity architecture.
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Couple of terms we will encounter frequently are Docker Images and Docker
|
Couple of terms we will encounter frequently are Docker Images and Docker
|
||||||
Containers. Images are packages or templates of containers all stored in the
|
Containers. Images are packages or templates of containers all stored in a
|
||||||
[Docker Hub](https://hub.docker.com/). Containers are standalone, executable
|
container registry such as [Docker Hub](https://hub.docker.com/). Containers
|
||||||
instances of these images which include code, runtime, system tools, system
|
are standalone, executable instances of these images which include code,
|
||||||
libraries and settings - everything required to get the software up and running.
|
runtime, system tools, system libraries and settings - everything required to
|
||||||
Coming to Docker, it follows a client-server architecture wherein the CLI client
|
get the software up and running. Coming to Docker, it follows a client-server
|
||||||
communicates with the server component, which here is, the Docker Engine using
|
architecture wherein the CLI client communicates with the server component,
|
||||||
RESTful API to issue commands.
|
which here is, the Docker Engine using RESTful API to issue commands.
|
||||||
|
|
||||||
## The Docker CLI
|
## The Docker CLI
|
||||||
```bash
|
```bash
|
||||||
# after installing Docker from https://docs.docker.com/get-docker/
|
# after installing Docker from https://docs.docker.com/get-docker/
|
||||||
# To list available commands, either run `docker` with no parameters or execute
|
# To list available commands, either run `docker` with no parameters or execute
|
||||||
# `docker help`
|
# `docker help`
|
||||||
$docker
|
$ docker
|
||||||
|
|
||||||
>>> docker [OPTIONS] COMMAND [ARG...]
|
>>> docker [OPTIONS] COMMAND [ARG...]
|
||||||
docker [ --help | -v | --version ]
|
docker [ --help | -v | --version ]
|
||||||
@@ -107,15 +107,15 @@ $docker
|
|||||||
attach Attach to a running container
|
attach Attach to a running container
|
||||||
# […]
|
# […]
|
||||||
|
|
||||||
$docker run hello-world
|
$ docker run hello-world
|
||||||
# `docker run <container-name>` is used to run a container, it will pull the
|
# `docker run <container-name>` is used to run a container, it will pull the
|
||||||
# images from Docker Hub if they don't alrady exist on your system. Here the
|
# images from Docker Hub if they don't already exist in your system. Here the
|
||||||
# docker client connects to the daemon which in turn pulls the "hello-world"
|
# docker client connects to the daemon which in turn pulls the "hello-world"
|
||||||
# image from the Docker Hub. The daemon then creates a new container from the
|
# image from the Docker Hub. The daemon then builds a new container from the
|
||||||
# image which runs the executable that produces the output streamed back to the
|
# image which runs the executable that produces the output streamed back to the
|
||||||
# client that we see on our terminals.
|
# client that we see on our terminals.
|
||||||
|
|
||||||
$docker run -d ubuntu sleep 60s
|
$ docker run -d ubuntu sleep 60s
|
||||||
# The -d (or --detach) flag is when we want to run a container in the background
|
# The -d (or --detach) flag is when we want to run a container in the background
|
||||||
# and return back to the terminal. Here we detach an ubuntu container from the
|
# and return back to the terminal. Here we detach an ubuntu container from the
|
||||||
# terminal, the output should be the id and the command exits. If we check
|
# terminal, the output should be the id and the command exits. If we check
|
||||||
@@ -123,19 +123,21 @@ $docker run -d ubuntu sleep 60s
|
|||||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
# 133261b4894a ubuntu "sleep 60s" 3 seconds ago Up 2 seconds vigorous_gould
|
# 133261b4894a ubuntu "sleep 60s" 3 seconds ago Up 2 seconds vigorous_gould
|
||||||
|
|
||||||
$docker run <container-id> -p 3000:8000
|
$ docker run <container-id> -p 3000:8000
|
||||||
# The -p (or --publish) flag is used to expose port 8000 inside the container to
|
# The -p (or --publish) flag is used to expose port 8000 inside the container to
|
||||||
# port 3000 outside the container. This is because the app inside the container
|
# port 3000 outside the container. This is because the app inside the container
|
||||||
# runs in isolation, hence the port 8000 where the app runs is private to the
|
# runs in isolation, hence the port 8000 where the app runs is private to the
|
||||||
# container.
|
# container.
|
||||||
|
|
||||||
$docker run -i or $docker run -it
|
$ docker run -i
|
||||||
|
# or
|
||||||
|
$ docker run -it
|
||||||
# Docker runs our containers in a non-interactive mode i.e. they do not accept
|
# Docker runs our containers in a non-interactive mode i.e. they do not accept
|
||||||
# inputs or work dynamically while running. The -i flag keeps input open to the
|
# inputs or work dynamically while running. The -i flag keeps input open to the
|
||||||
# container, and the -t flag creates a pseudo-terminal that the shell can attach
|
# container, and the -t flag creates a pseudo-terminal that the shell can attach
|
||||||
# to (can be combined as -it)
|
# to (can be combined as -it)
|
||||||
|
|
||||||
$docker ps -a
|
$ docker ps -a
|
||||||
# The `docker ps` command only shows running containers by default. To see all
|
# The `docker ps` command only shows running containers by default. To see all
|
||||||
# containers, use the -a (or --all) flag
|
# containers, use the -a (or --all) flag
|
||||||
# Running the above command should output something similar in the terminal:
|
# Running the above command should output something similar in the terminal:
|
||||||
@@ -143,12 +145,14 @@ $docker ps -a
|
|||||||
# 82f84bf6912b hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago eloquent_sammet
|
# 82f84bf6912b hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago eloquent_sammet
|
||||||
|
|
||||||
|
|
||||||
$docker start hello-world or $docker stop hello-world
|
$ docker stop hello-world
|
||||||
# The stop command simply stops one or more containers, the start command starts
|
# or
|
||||||
# the conatainer(s) up again! `docker start -a ubuntu` will attach our detached
|
$ docker start hello-world
|
||||||
# container back to the terminal i.e. runs in the foreground
|
# The stop command simply stops one or more containers, and the start command
|
||||||
|
# starts the container(s) up again! `docker start -a ubuntu` will attach our
|
||||||
|
# detached container back to the terminal i.e. runs in the foreground
|
||||||
|
|
||||||
$docker create alpine
|
$ docker create alpine
|
||||||
# `docker create` creates a new container for us with the image specified (here,
|
# `docker create` creates a new container for us with the image specified (here,
|
||||||
# alpine), the container does not auto-start unlike `docker run`. This command
|
# alpine), the container does not auto-start unlike `docker run`. This command
|
||||||
# is used to set up a container configuration and then `docker start` to shoot
|
# is used to set up a container configuration and then `docker start` to shoot
|
||||||
@@ -156,12 +160,12 @@ $docker create alpine
|
|||||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
# 4c71c727c73d alpine "/bin/sh" 29 seconds ago Created naughty_ritchie
|
# 4c71c727c73d alpine "/bin/sh" 29 seconds ago Created naughty_ritchie
|
||||||
|
|
||||||
$docker rm 82f84
|
$ docker rm 82f84
|
||||||
# Removes one or more containers using their container ID.
|
# Removes one or more containers using their container ID.
|
||||||
# P.S.: we can use only the first few characters of the entire ID to identify
|
# P.S.: we can use only the first few characters of the entire ID to identify
|
||||||
# containers
|
# containers
|
||||||
|
|
||||||
$docker images
|
$ docker images
|
||||||
# Displays all images and their information, created here means the latest image
|
# Displays all images and their information, created here means the latest image
|
||||||
# tag updated on Docker Hub:
|
# tag updated on Docker Hub:
|
||||||
# REPOSITORY TAG IMAGE ID CREATED SIZE
|
# REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||||
@@ -169,21 +173,21 @@ $docker images
|
|||||||
# alpine latest 9c6f07244728 3 months ago 5.54MB
|
# alpine latest 9c6f07244728 3 months ago 5.54MB
|
||||||
# hello-world latest feb5d9fea6a5 13 months ago 13.3kB
|
# hello-world latest feb5d9fea6a5 13 months ago 13.3kB
|
||||||
|
|
||||||
$docker rmi
|
$ docker rmi
|
||||||
# Removes one or more images from your system which do not have their instances
|
# Removes one or more images from your system which do not have their instances
|
||||||
# (or containers as we know them) running. If the image has an attached
|
# (or containers as we know them) running. If the image has an attached
|
||||||
# container, either delete the container first or use the -f (or --force) flag
|
# container, either delete the container first or use the -f (or --force) flag
|
||||||
# to forcefully delete both the container and image.
|
# to forcefully delete both the container and image.
|
||||||
|
|
||||||
$docker pull busybox
|
$ docker pull busybox
|
||||||
# The pull command downloads the specified image on our system from Docker Hub.
|
# The pull command downloads the specified image on our system from Docker Hub.
|
||||||
|
|
||||||
$docker exec -it 7b272 bash
|
$ docker exec -it 7b272 bash
|
||||||
# This command is used to run a command in the running container's default
|
# This command is used to run a command in the running container's default
|
||||||
# directory. Here 7b272 was our ubuntu container and the above command would
|
# directory. Here 7b272 was our ubuntu container and the above command would
|
||||||
# help us interact with the container by opening a bash session
|
# help us interact with the container by opening a bash session.
|
||||||
|
|
||||||
$docker compose
|
$ docker compose
|
||||||
|
|
||||||
# More commands can be found at https://docs.docker.com/engine/reference/commandline/docker/
|
# More commands can be found at https://docs.docker.com/engine/reference/commandline/docker/
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user