Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Docker – ARG Directive, .dockerignore, and Docker Volumes

ARG Directive The ARG directive acts like a variable. We can define it inside the Dockerfile and change its value during the image build process. ARG PYTHON_VERSION=3.8 FROM python:${PYTHON_VERSION}-slim Here, the Python version…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




ARG Directive



The ARG directive acts like a variable. We can define it inside the Dockerfile and change its value during the image build process.




ARG PYTHON_VERSION=3.8
FROM python:${PYTHON_VERSION}-slim






Here, the Python version in the Dockerfile is set to 3.8. However, during the build process, we can change it to 3.10.




docker build -f Dockerfile --build-arg PYTHON_VERSION=3.10 -t helloworld_flask:v1 .








  • -t means tag.


  • -f means Dockerfile path.



We can use ARG to make base image versions and other build-time values configurable.






Example






FROM node:20-alpine

# 1. Define the arguments
ARG APP_DIR=app
ARG INSTALL_ARGS="--omit=dev"

# 2. Use them in instructions
WORKDIR /${APP_DIR}
COPY . .
RUN npm install ${INSTALL_ARGS}






Note: ARG values can only be changed during the image build process. They cannot be changed during container creation.









Docker Ignore



A .dockerignore file is used to specify files and directories that should not be copied into the Docker build context.



Create a file named .dockerignore in the application's root directory.



Examples of files and folders that can be ignored:




Dockerfile
.venv
__pycache__
*.pyc
requirements.txt
.git
.gitignore






Ignoring unnecessary files reduces the build context size and speeds up image builds.









Docker Volumes



Generally, when a container is created, a writable layer is also created.



If we create files inside the container, they are stored in the writable layer. However, when the container is deleted, all data in the writable layer is lost.



What if we need to store files permanently on the host machine?



This is where Docker volumes come into the picture.



Docker volumes allow data to persist independently of the container lifecycle.



When a volume is mounted between a host directory and a container directory:




  • Files created in the container appear on the host machine.

  • Files created on the host machine appear inside the container.

  • Changes are synchronized between both locations.









Types of Docker Volumes




  1. Bind-Mounted Volumes

  2. Docker Managed Volumes (Named Volumes)









1. Bind-Mounted Volumes



A bind mount creates a mapping between a host directory and a container directory.




docker run -it -v ./data:/data busybox:1.36 sh






Here:





  • ./data = Host machine directory


  • /data = Container directory



Characteristics:




  • Tightly coupled with the host file system.

  • Multiple containers can share the same host directory.

  • Changes made in either location are reflected in the other.



Note: The host directory is not deleted when the container is removed.









2. Docker Managed Volumes (Named Volumes)



Create a Docker-managed volume:




docker volume create dockersession






This creates a volume outside the container lifecycle.






List Volumes






docker volume ls









Inspect a Volume






docker volume inspect dockersession






This displays information about the volume, including its mount location.



Example Linux location:




/var/lib/docker/volumes/dockersession/_data









Mount the Volume to a Container






docker run -it -v dockersession:/data123 busybox:1.36 sh






Here:





  • dockersession = Volume name


  • /data123 = Container directory



Multiple containers can use the same volume for data sharing.






Find Containers Using a Specific Volume






docker ps -a --filter volume=dockersession






One of the major benefits of Docker volumes is that they are completely decoupled from the container lifecycle.



When a container is deleted, the volume and all its data remain safely stored on the host machine.









Interview Questions






Question:



What is the primary use of the ARG instruction in Docker?



Answer: To pass build-time variables to the Dockerfile.









Question:



Which of the following is true about ARG variables in Docker?



Answer: They are used only during the image build process.









Question:



Can an ARG variable be used in a RUN instruction within a Dockerfile?



Answer: Yes, but only after it has been declared.









Question:



Which files can be ignored using .dockerignore?



Answer: Any file or directory within the build context.









Question:



What is the purpose of Docker volumes?



Answer: To store data that persists even after a container is destroyed.









Question:



What is the default location of Docker volumes on Linux systems?



Answer:




/var/lib/docker/volumes












Question:



Which command allows you to list all Docker volumes?



Answer:




docker volume ls












Question:



In which scenario would you use a bind-mounted volume?



Answer: When you need to share specific directories between the host machine and a container.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Docker – ARG Directive, .dockerignore, and Docker Volumes

Thematisch verwandte Begriffe: Docker, Directive, dockerignore, Volumes · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick