Save
...
Infrastructure
Docker
Hands-On
Save
Share
Learn
Content
Leaderboard
Learn
Created by
GiganticAngonoka72710
Visit profile
Subdecks (1)
Commands
ML Security > Infrastructure > Docker > Hands-On
28 cards
Cards (39)
Launch containers with docker
run
redis
docker version to view details about the Docker client and server.
Docker is a
two-part
system:
client
and
engine
communicate via various
protocols.
docker
run -d -p 8800
:
80
httpd
-d: Detach, runs the container in the background.
-p 8800
:
80
: Publishes container's port 80 on host's port
8800.
httpd: Apache
HTTP
server image.
Use
curl
localhost:
8800
to verify the Apache server
Run docker
ps
to display running containers; you should see one.
To run a second Apache server on a different port, execute:
-docker run -d -p 8801:80
httpd
Docker downloads the image and creates separate containers (Container 1 and Container 2).
Each container has a
private
IP with port
80
inside Docker's virtual networking.
External
ports (
8800
, 8801) map to the containers' internal ports.
Docker
Version
:
Command: docker version
Returns the version of the Docker
client
and
server
(engine).
Ensure both client and server versions are
up-to-date
for
optimal compatibility.
Docker
Info
:
Command: docker
info
Provides
detailed
information about Docker engine
configuration.
Includes data on
containers
,
images
, and other engine
settings.
Review of Commands:
docker version:
Check
client and server
versions
for compatibility.
docker info: Obtain detailed information about Docker engine
configuration.
docker:
List
available Docker
commands.
Command
Structure
: Old commands (e.g., docker run)
coexist
with new
management
commands (e.g., docker container run).
Image vs. Container:
Image:
Binaries
,
libraries
, and
source
code that constitute an
application.
Container: A
running instance
of an image.
Multiple containers
can be based on the same
image.
Image Registries:
Registries (e.g., Docker Hub)
host container images
,
analogous
to GitHub for
source code.
Docker images
are pulled from
registries
when needed.
Practical Exercise: Running Nginx Container
Use the command: docker container
run
-p 80:80 nginx
Explain the command parts:
-p
80
:80: Publishes
local port
80 to container's port
80.
nginx: Specifies the
image
(Nginx web server).
Access Nginx server in a browser at localhost.
Listing
and
Stopping Containers
:
List running containers: docker container
ls.
Stop a
container
: docker
container stop
<container_id>.
Container Logs:
Generate logs by
refreshing
the browser.
View logs with: docker
container
logs <container_
name
>.
Inspecting Containers:
Use docker container
top
<container_name> to view container
processes.
Explore additional container
commands
with docker container
--help.
docker container ls -a
lists all
containers
, including ones that have been
stopped
removing multiple containers:
docker container
rm
{ids of containers}
Note: You cannot remove a running docker container, you first must stop it or use this command to force remove it:
docker container rm -f
See all 39 cards