THE 🐳IS BACK !!! 🧵🧵🧵

During these days, even if you have seen not that much from the social point of view, I have continued working on Docker and I am thinking about something you could enjoy in the future!

In the meanwhile, here is a Thread of useful Docker Tips

👇👇👇
DOCKER DESKTOP
Dockerfile keywords
DOCKER EXEC

Execute commands on currently running containers.

The most popular usage is to launch a Terminal in a running container, keeping the STDIN open and allocating a pseudo-TTY.

Example:
"docker exec -it <cont_ID> /bin/bash"
HEALTHCHECK in Dockerfiles

Healthchecks are what they sound like: a way to check if the container is 'healthy'. You can specify an healthcheck to check if a container is running properly.

They are very important in a real-world scenario and production-ready applications
DOCKER COMPOSE
Multiple compose files:

By default, Compose reads 2 files:
- docker-compose.yml (base config)
- docker-compose.override.yml file (to override config)

If a service is defined in both files, configurations are merged, useful for development

Docker-compose commands
docker stats [OPTIONS] [CONTAINER...]
returns a live data stream for containers.

Below a custom command, using GO template, that shows additional info you can try.

docker stats -a --format "table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.BlockIO}}"
DELETE ALL NOT RUNNING CONTAINERS
CHECK ENVIRONMENT VARIABLES OF AN IMAGE
DOCKER TOP: Displays the container's running processes
DOCKER PORT: Lists container's port mappings
DOCKER KILL: Kills the process! (not ideal)
DOCKER DIFF
An handy command to check any changes to:
-files
-directories

on the container’s filesystem

A: added file or directory
C: changed file or directory was
D: deleted file or directory

Usage:
docker diff <container_ID/container_name>
docker container ps [OPTIONS]
(you can use the shortcut: "docker ps [OPTIONS]")

-a: show all containers, even the stopped ones
-q: only show IDS
-l: show the latest container
-s: show the size
-f: filter output
--format: show using GO template (example below)
DOCKER TAG:
docker tag <image> <new tag>

Effect:
Create a tag image that refers to the source image

A tag must be:
- valid ASCII
- may contain letters, digits, underscores, periods, dashes.
- may not start with a period or a dash
- maximum of 128 characters.
DOCKER VOLUMES:
The preferred mechanism for persisting data for Docker containers

- Special directory for containers
- Designed to persist data
- No automatically deleted
- No garbage-collected when no more referenced

Types:

-HOST VOLUMES
-NAMED VOLUMES
-ANONYMOUS VOLUMES
DOCKER UN OPTIONS:

-d: detached mode
-e: set/override env variable
-i: Keep STDIN open
--name: assign name
--network: define network
-p: publish ports
-P: publish all the ports to the host interfaces
--rm: remove on exit
-t: pseudo-tty
-u: user
-v: volume
-w: default workdir
Containers pro over VMs:

1⃣Dev-Friendly

2⃣Smaller Snapshots (Images)

3⃣Public Registry (Docker Hub)

4⃣Faster startup (seconds, no minutes)

5⃣Less Resource-Consuming (Processes)

6⃣The App runs independently on computer/OS

7⃣New containers can be created on-demand quickly
.dockerignore file
DOCKER PRUNE COMMANDS
DOCKER STOP / DOCKER RM deep dive

What happens when we use these commands?

How can we send a SIGNAL to a container?
Docker Volume PRO over Bind-Mount:

1⃣Easier back up/migration
2⃣Manageable by Docker CLI/API
3⃣Work on Linux/Windows containers
4⃣Shared safer among containers
5⃣Storable on remote hosts/cloud providers to encrypt contents/add functionalities
6⃣Can have content pre-populated
DOCKER NAMESPACES

Docker is written in Go and takes advantage of several features of the Linux kernel to deliver its functionality.

One of these is 'Namespaces':
The Docker Engine combines
- namespaces
- cgroups
- UnionFS

To define a container format.

Current: libcontainer
DOCKER CMD & ENTRYPOINT
DOCKERFILE GO EXAMPLE
DOCKER MINIMALISTIC DEFINITIONS (Thread)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Francesco Ciulla

Francesco Ciulla Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @FrancescoCiull4

24 Nov
🐳Some cool programs that you can start without installing them using Docker (Thread)

1-🤵JENKINS
2- 🐘POSTGRES
3- ⚓️PORTAINER
4- 🔴REDIS
5- 🐘🌐PGADMIN
6- 🌀GRAFANA

👇👇👇
🤵‍♂️JENKINS : free, open source automation server.

You can just start using it using its official docker image"
docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

To remove, just remove the container and the image:
docker rmi -f jenkins/jenkins:lts

Try it!
🐳🐘POSTGRES

In 2 commands, run a Postgres container and get into PSQL

1.
docker run --name testpostgres -p 5432:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=testdb -d postgres:latest

2.
docker exec -it postgresql psql -d testdb -U admin
Read 7 tweets
19 Oct
🐳A thread of minimalistic definitions of some Docker elements:

- Docker host
- Docker engine
- Docker client
- Dockerfile
- Docker image
- Docker container
- Docker Compose
- Docker Registry
- Docker Swarm

Definitions Below 👇👇👇

//And by the way, I already know that it's...
Docker (Active) Host

A computer with Docker installed and the daemon running.
It can process Docker and non-Docker workloads.
Docker Engine

A Client-Server application. It has 3 components:

"daemon process": A server which is a type of long-running program.

"Rest API": to specify interfaces that programs can use to talk and interact with the daemon.
Read 10 tweets
23 Sep
This morning, I took some time to look at the YouTube channels that I am subscribed to.

I collected the programming videos that you might be interested in, and I decided to put some of them in a MEGA-THREAD

Support these great content creators!!!

All include code, EXCEPT ONE
@thisismanaswini
Make a Minion using just HTML and CSS
@benawad
Should You Stop Using React
Read 25 tweets
19 Sep
Devops Articles I have read today :) 👇
Microsoft Adds Windows Subsystem for Linux 2 Support in Windows 10 Versions 1903 and 1909

redmondmag.com/articles/2020/…
Istio 1.7: Security improvements take centre stage as users continue to speculate about the service mesh’s future

devclass.com/2020/08/24/ist…
Read 4 tweets
17 Sep
I spend 1/2 hours per day to stay updated about the DevOps World, which is huge.

4 Articles I am reading right now:
👇👇👇
Pure Storage spends $370m on the acquisition of Kubernetes platform Portworx

capacitymedia.com/articles/38263…
HOW KUBERNETES PROVIDES NETWORKING AND STORAGE TO APPLICATIONS

thenewstack.io/how-kubernetes…
Read 5 tweets
16 Sep
I spent some time today exploring the official Docker repositories on GitHub.

In the links below those that interested me the most:

👇👇👇
GitHub Action to build and push Docker images with Buildx.
github.com/docker/build-p…
Docker CLI plugin for Amazon ECS
github.com/docker/ecs-plu…
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!