Docker Notes
Docker Notes
/ # hostname
f1695de1f2ec
/ # date
Thu Jun 20 12:18:26 UTC 2019
run to start the app, logs to read out the logs, top to see the
processes, and inspect to get the details.
docker container run -P = take all ports form container and connect to random port
on host computer
ch3
docker image build --tag web-ping . = build new docker image from files from
current directory "." and the name of images comes from --tag web-ping
docker image ls 'w*' = List all the images where the tag name starts with �w�:
Any Dockerfile you write should be optimized so that the instructions are ordered
by how frequently they change�with instructions that are unlikely to change at the
start of the Dockerfile, and instructions most likely to change at the end.
localhost = http://192.168.99.100:8080/
FROM alpine:latest = choose base image which is operating system linux alpine with
latest version.
docker image build --tag local:fromscratch . = locate the folder with dockerfile
using cd command in powershell and then run command, local = local repository,
fromscratch = name of the image.
Docer shipswith several built-in drivers, known as native drivers or local drivers.
On Linux they include; bridge,
overlay, and macvlan. On Windows they include; nat, overlay, transparent, and
l2bridge.
Docker volumes:
docker container run -d --name tolik -v /c/Users/Greg/filess:/app nginx
docker container run -d --name tolik --mount
'type=volume,source=filesss,target=/app' nginx
Chapter 2#
FROM ubuntu:20.04
FROM scratch
LABEL <key>=<value>
LABEL [email protected] version=1.0 environment=dev
ARG <varname>
ARG USER
ARG VERSION
ARG USER=TestUser
ARG VERSION=1.0.0
WORKDIR /one
WORKDIR two
WORKDIR three
RUN pwd
/one/two/three.
The www-data user is the default user for the Apache web server
on Ubuntu.
VOLUME ["/path/to/volume"]
VOLUME /path/to/volume1 /path/to/volume2
ENV DEBIAN_FRONTEND=noninteractive
"Source": "/mnt/sda1/var/lib/docker/volumes/a600c1d8a
EXPOSE <port>
docker container run -p <host_port>:<container_port> <image>
ONBUILD <instruction>
When building an image from a Dockerfile, layers are created when the RUN,ADD, and
COPY commands are used.
major_version.minor_version.patch
<account_name>/<image_name>:tag
FROM ubuntu:focal
RUN apt-get update
RUN useradd demo-user
USER demo-user
CMD whoami
FROM ubuntu:focal
RUN apt-get update \
&& apt-get install --no-install-recommends -y nginx
FROM ubuntu:focal
RUN apt-get update \
&& apt-get install --no-install-recommends -y nginx \
&& rm -rf /var/lib/apt/lists/*
server:
env_file:
- database.env
docker node ls
docker service create --name <service> <image> <command>
docker service update <service> <changes>
docker service remove <service>
docker service scale web=3
docker node update --availability drain j2qxrpf0a1yhvcax6n2ajux69