Skip to contentমূল লেখায় যান

Topic 08 · DevOps & Cloudটপিক 08 · DevOps & Cloud

Docker in Practice

This page is about the everyday work with containers in testing: where test data lives (volumes, bind mounts, and tmpfs), how containers find each other on a network, and the commands that show what a container holds and uses, with a practice run of each. It builds on Docker Basics and Docker Images and Compose.

12 min read12 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 12 sources12টি সোর্স · updated Nov 2026আপডেট: Nov 2026

Data survives only in a mountডেটা টিকে শুধু মাউন্টে

Remove a container and see which data is gone and which stays. Switch between a volume and a bind mount.একটা কনটেইনার মুছে ফেলুন আর দেখুন কোন ডেটা যায় আর কোনটা থাকে। ভলিউম আর বাইন্ড মাউন্টের মধ্যে বদলান।

2 min2 মিনিট6 steps6টি ধাপ
  • Layer filesলেয়ারের ফাইল3
  • Mount filesমাউন্টের ফাইল0
  • Host changedহোস্ট বদলেছে0
writeলেখাContainerকনটেইনারAAContainerকনটেইনারBBWritableরাইটেবলlayerলেয়ারVolumeভলিউমmyvol2myvol2Hostহোস্টfolderফোল্ডার3 files3 ফাইল

You’ll learnআপনি শিখবেন

  • Why layer data is lost with the containerকনটেইনারের সাথে লেয়ারের ডেটা কেন যায়
  • Why a bind mount can change the hostbind mount কেন হোস্ট বদলাতে পারে
  • What the ro option doesro অপশন কী করে
  • How a volume outlives its containerভলিউম কীভাবে কনটেইনারের পরও থাকে
  • A volume is not removed by itselfভলিউম নিজে থেকে মোছে না

What it is

Data in a container. By default, all files created inside a container are stored on a writable container layer Source 1সোর্স 1. Data written to the container layer doesn't persist when the container is destroyed Source 1সোর্স 1. Docker supports storage mounts for storing data outside the writable layer of the container, among them volume mounts, bind mounts, and tmpfs mounts Source 1সোর্স 1. No matter which type of mount you choose to use, the data looks the same from within the container Source 1সোর্স 1.

MountWhat it isUse it for
VolumeA persistent data store for containers, created and managed by Docker Source 2সোর্স 2Volumes are the preferred mechanism for persisting data generated by and used by Docker containers Source 2সোর্স 2
Bind mountA file or directory on the host machine, mounted from the host into a container Source 3সোর্স 3Sharing source code or build artifacts between a development environment on the Docker host and a container Source 3সোর্স 3
tmpfs mountTemporary, and only persisted in the host memory; when the container stops, the tmpfs mount is removed Source 4সোর্স 4Non-persistent state data that should not be stored anywhere permanently Source 2সোর্স 2

Networks. All containers without a --network specified are attached to the default bridge network Source 5সোর্স 5. Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy Source 5সোর্স 5. User-defined bridges provide automatic DNS resolution between containers Source 5সোর্স 5.

সহজ English

Data in a container. By default, every file that a container creates goes into a writable layer Source 1সোর্স 1. When the container is destroyed, that data is gone Source 1সোর্স 1. To keep data outside that layer, Docker has storage mounts, among them volume mounts, bind mounts, and tmpfs mounts Source 1সোর্স 1. Whichever mount you choose, the data looks the same from inside the container Source 1সোর্স 1.

MountWhat it isUse it for
VolumeA store for data that lasts, made and managed by Docker Source 2সোর্স 2The preferred way to keep data that containers make and use Source 2সোর্স 2
Bind mountA file or folder of the host machine, mounted into a container Source 3সোর্স 3Sharing source code or build results between the Docker host and a container Source 3সোর্স 3
tmpfs mountTemporary, kept only in the host's memory; when the container stops, it is removed Source 4সোর্স 4Data that does not need to last and should not be stored anywhere for good Source 2সোর্স 2

Networks. A container started without --network joins the default bridge network Source 5সোর্স 5. On the default bridge network, containers can reach each other only by IP address, unless you use the old --link option Source 5সোর্স 5. A bridge network that you create yourself gives its containers automatic DNS resolution between them Source 5সোর্স 5.

বাংলা ব্যাখ্যা

container-এর ভেতরের data। default-ভাবে container-এর ভেতরে তৈরি সব file একটা writable container layer-এ থাকে Source 1সোর্স 1। container ধ্বংস হলে container layer-এ লেখা data থাকে না Source 1সোর্স 1। container-এর writable layer-এর বাইরে data রাখতে Docker কয়েক ধরনের storage mount দেয়, যার মধ্যে আছে volume mount, bind mount আর tmpfs mount Source 1সোর্স 1। যে mount-ই বেছে নিন, container-এর ভেতর থেকে data একই রকম দেখায় Source 1সোর্স 1।

Mountএটা কীকীসের জন্য
Volumecontainer-এর জন্য একটা persistent data store, যা Docker তৈরি ও পরিচালনা করে Source 2সোর্স 2Docker container-এর তৈরি ও ব্যবহৃত data টিকিয়ে রাখার পছন্দের উপায় হলো volume Source 2সোর্স 2
Bind mounthost machine-এর একটা file বা directory, host থেকে container-এ mount করা Source 3সোর্স 3Docker host-এর development environment আর একটা container-এর মধ্যে source code বা build artifact share করা Source 3সোর্স 3
tmpfs mountঅস্থায়ী, শুধু host-এর memory-তে থাকে; container থামলে tmpfs mount সরিয়ে ফেলা হয় Source 4সোর্স 4এমন non-persistent state data, যা কোথাও স্থায়ীভাবে রাখার দরকার নেই Source 2সোর্স 2

Network। --network উল্লেখ না করা সব container default bridge network-এ যুক্ত হয় Source 5সোর্স 5। default bridge network-এর container-গুলো একে অপরকে শুধু IP address দিয়ে পৌঁছাতে পারে, যদি না আপনি legacy বলে গণ্য --link option ব্যবহার করেন Source 5সোর্স 5। user-defined bridge container-গুলোর মধ্যে automatic DNS resolution দেয় Source 5সোর্স 5।

How it works

A volume outlives its container. A volume's contents exist outside the lifecycle of a given container Source 2সোর্স 2. When a container is destroyed, the writable layer is destroyed with it, but using a volume ensures that the data is persisted even if the container using it is removed Source 2সোর্স 2. A given volume can be mounted into multiple containers simultaneously Source 2সোর্স 2. When no running container is using a volume, the volume is still available to Docker and isn't removed automatically Source 2সোর্স 2.

Two flags to mount. To mount a volume with docker run, you can use either the --mount or the --volume flag Source 2সোর্স 2. In general, --mount is preferred: it is more explicit and supports all the available options Source 2সোর্স 2.

Mount--mount formShort form
Volume--mount type=volume,src=<volume-name>,dst=<mount-path> Source 2সোর্স 2--volume <volume-name>:<mount-path> Source 2সোর্স 2
Bind mount--mount type=bind,src=<host-path>,dst=<container-path> Source 3সোর্স 3--volume <host-path>:<container-path> Source 3সোর্স 3
tmpfs--mount type=tmpfs,dst=<mount-path> Source 4সোর্স 4--tmpfs <mount-path> Source 4সোর্স 4

Mounting over files. If you mount a non-empty volume into a directory in the container in which files or directories exist, the pre-existing files are obscured by the mount Source 2সোর্স 2. If you mount an empty volume there, these files or directories are propagated (copied) into the volume by default Source 2সোর্স 2.

Named and anonymous volumes. A volume may be named or anonymous; anonymous volumes are given a random name Source 2সোর্স 2. Like named volumes, anonymous volumes persist even if you remove the container that uses them, except if you use the --rm flag when creating the container Source 2সোর্স 2.

Bind mounts can change the host. Bind mounts have write access to files on the host by default Source 3সোর্স 3. A process in the container can change the host filesystem, including creating, modifying, or deleting important system files or directories Source 3সোর্স 3. You can use the readonly or ro option to prevent the container from writing to the mount Source 3সোর্স 3.

Names on a network. On the default bridge network, containers can't resolve each other by name Source 5সোর্স 5. On user-defined networks, containers can resolve each other by name Source 5সোর্স 5. Automatic service discovery only resolves custom container names, not default automatically generated names Source 5সোর্স 5. This diagram is the tutorial's own picture of step 4 of the practice run below:

alpine-net (user-defined)
┌─────────────────────────────┐
│ alpine1 ── ping ──> alpine2 │
└─────────────────────────────┘
bridge (default)
┌─────────┐
│ alpine3 │
└─────────┘

alpine1 ── ping alpine3 ──X
ping: bad address 'alpine3'

সহজ English

A volume lives longer than its container. What is in a volume lives outside the life of any one container Source 2সোর্স 2. When a container is destroyed, its writable layer goes with it, but the data in a volume stays, even when the container that used it is removed Source 2সোর্স 2. One volume can be mounted into many containers at the same time Source 2সোর্স 2. When no running container uses a volume, Docker still keeps it; it is not removed by itself Source 2সোর্স 2.

Two flags to mount. To mount a volume with docker run, you can use --mount or --volume Source 2সোর্স 2. Most of the time, --mount is the better choice: it says more clearly what you want, and it supports all the options Source 2সোর্স 2.

Mount--mount formShort form
Volume--mount type=volume,src=<volume-name>,dst=<mount-path> Source 2সোর্স 2--volume <volume-name>:<mount-path> Source 2সোর্স 2
Bind mount--mount type=bind,src=<host-path>,dst=<container-path> Source 3সোর্স 3--volume <host-path>:<container-path> Source 3সোর্স 3
tmpfs--mount type=tmpfs,dst=<mount-path> Source 4সোর্স 4--tmpfs <mount-path> Source 4সোর্স 4

Mounting over files. If you mount a volume that already has data onto a folder that already has files, the mount hides those files Source 2সোর্স 2. If the volume is empty, Docker copies those files into the volume by default Source 2সোর্স 2.

Named and anonymous volumes. A volume can have a name, or be anonymous; an anonymous volume gets a random name Source 2সোর্স 2. Like named volumes, anonymous volumes stay after you remove their container, unless you started the container with --rm Source 2সোর্স 2.

Bind mounts can change the host. By default, a bind mount can write to files on the host Source 3সোর্স 3. A process in the container can change the host's file system, and even create, change, or delete important system files or folders Source 3সোর্স 3. The readonly or ro option stops the container from writing to the mount Source 3সোর্স 3.

Names on a network. On the default bridge network, containers cannot find each other by name Source 5সোর্স 5. On networks that you create, they can Source 5সোর্স 5. This works only for names that you give the containers, not for the names that Docker makes up Source 5সোর্স 5. This diagram is the tutorial's own picture of step 4 of the practice run below:

alpine-net (user-defined)
┌─────────────────────────────┐
│ alpine1 ── ping ──> alpine2 │
└─────────────────────────────┘
bridge (default)
┌─────────┐
│ alpine3 │
└─────────┘

alpine1 ── ping alpine3 ──X
ping: bad address 'alpine3'

বাংলা ব্যাখ্যা

volume তার container-এর চেয়ে বেশিদিন টেকে। একটা volume-এর বিষয়বস্তু কোনো একটা container-এর lifecycle-এর বাইরে থাকে Source 2সোর্স 2। container ধ্বংস হলে তার writable layer-ও যায়, কিন্তু volume ব্যবহার করলে সেটা ব্যবহার করা container মুছে ফেলার পরও data থেকে যায় Source 2সোর্স 2। একটা volume একসাথে একাধিক container-এ mount করা যায় Source 2সোর্স 2। কোনো চলমান container একটা volume ব্যবহার না করলেও Docker-এর কাছে সেটা থাকে, নিজে থেকে মোছে না Source 2সোর্স 2।

mount করার দুটো flag। docker run-এ volume mount করতে --mount বা --volume, যেকোনো একটা flag ব্যবহার করা যায় Source 2সোর্স 2। সাধারণভাবে --mount বেশি পছন্দনীয়: এটা বেশি স্পষ্ট, আর সব option সমর্থন করে Source 2সোর্স 2।

Mount--mount রূপছোট রূপ
Volume--mount type=volume,src=<volume-name>,dst=<mount-path> Source 2সোর্স 2--volume <volume-name>:<mount-path> Source 2সোর্স 2
Bind mount--mount type=bind,src=<host-path>,dst=<container-path> Source 3সোর্স 3--volume <host-path>:<container-path> Source 3সোর্স 3
tmpfs--mount type=tmpfs,dst=<mount-path> Source 4সোর্স 4--tmpfs <mount-path> Source 4সোর্স 4

file-এর ওপর mount করা। container-এর যে directory-তে আগে থেকে file আছে, সেখানে data-ভরা একটা volume mount করলে আগের file-গুলো mount-এর আড়ালে ঢাকা পড়ে Source 2সোর্স 2। খালি volume mount করলে default-ভাবে ওই file বা directory-গুলো volume-এ copy হয় Source 2সোর্স 2।

Named আর anonymous volume। একটা volume named বা anonymous হতে পারে; anonymous volume একটা random নাম পায় Source 2সোর্স 2। named volume-এর মতো anonymous volume-ও ব্যবহার করা container মুছে ফেলার পরও থেকে যায়, যদি না container তৈরির সময় --rm flag দেওয়া হয় Source 2সোর্স 2।

bind mount host বদলাতে পারে। default-ভাবে bind mount-এর host-এর file-এ লেখার অধিকার থাকে Source 3সোর্স 3। container-এর একটা process host-এর filesystem বদলাতে পারে, গুরুত্বপূর্ণ system file বা directory তৈরি, বদল বা মুছে ফেলাসহ Source 3সোর্স 3। container যাতে mount-এ লিখতে না পারে, সেজন্য readonly বা ro option ব্যবহার করা যায় Source 3সোর্স 3।

network-এ নাম। default bridge network-এ container-গুলো নাম দিয়ে একে অপরকে খুঁজে পায় না Source 5সোর্স 5। user-defined network-এ পায় Source 5সোর্স 5। automatic service discovery শুধু আপনার দেওয়া container-এর নাম resolve করে, Docker-এর নিজে বানানো নাম নয় Source 5সোর্স 5। এই diagram নিচের practice run-এর ধাপ ৪-এর টিউটোরিয়ালের নিজের ছবি:

alpine-net (user-defined)
┌─────────────────────────────┐
│ alpine1 ── ping ──> alpine2 │
└─────────────────────────────┘
bridge (default)
┌─────────┐
│ alpine3 │
└─────────┘

alpine1 ── ping alpine3 ──X
ping: bad address 'alpine3'

Try it

The tutorial ran these steps on 2026-11-16 with Docker Engine 29.9.3 on Linux, as a user in the docker group. The file contents (run 1: 12 passed, 1 passed) are the tutorial's own sample data. IDs, sizes, and paths differ on your machine.

1. Keep a result in a volume, and copy it out. If you start a container with a volume that doesn't yet exist, Docker creates the volume for you; the first command is Docker's own example, on one line Source 2সোর্স 2. docker exec runs a new command in a running container Source 6সোর্স 6. The command must be an executable, and a chained or a quoted command doesn't work, so the second command runs in sh -c, as Docker's example does Source 6সোর্স 6. docker cp works with a running or a stopped container Source 7সোর্স 7:

docker run -d --name devtest --mount source=myvol2,target=/app nginx:latest
docker exec devtest sh -c 'echo "run 1: 12 passed" > /app/result.txt'
docker container stop devtest
docker cp devtest:/app/result.txt ./result-copy.txt
docker container rm devtest
docker run --rm --mount source=myvol2,target=/app alpine cat /app/result.txt

In the tutorial's run, docker cp copied the file out of the stopped container, and ls -l result-copy.txt showed the user who ran docker cp as its owner. The last command starts a new container with the same volume. It printed run 1: 12 passed, the line that the removed container had written.

2. Write a report to the host. A bind mount puts a host folder into the container, and the container can write to it by default Source 3সোর্স 3:

mkdir reports
docker run --rm --mount type=bind,src="$(pwd)"/reports,dst=/reports alpine sh -c 'echo "1 passed" > /reports/result.txt'
cat reports/result.txt

In the tutorial's run, cat printed 1 passed, and ls -l reports showed that result.txt belonged to root, not to the user who ran the command.

3. See what a wrong path does. By default, --mount does not create a directory that does not exist on the host; it produces an error Source 3সোর্স 3. With --volume (-v), Docker creates the missing directory on the host for you, and it's always created as a directory Source 3সোর্স 3:

docker run --rm --mount type=bind,src="$(pwd)"/no-such-dir,dst=/reports alpine ls /reports
docker run --rm -v "$(pwd)"/typo-dir:/reports alpine ls -la /reports

In the tutorial's run, the first command printed docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: with the full path, and exited with code 125. The second one exited with 0: it created typo-dir on the host, owned by root, and ls -la in the container listed an empty /reports.

4. Let containers find each other by name. These commands follow Docker's tutorial on user-defined bridge networks, with three containers instead of its four; the -dit flags mean detached, interactive, and with a TTY Source 5সোর্স 5. Docker's tutorial attaches to alpine1 to run the ping Source 5সোর্স 5; here, docker exec runs it:

docker network create --driver bridge alpine-net
docker run -dit --name alpine1 --network alpine-net alpine ash
docker run -dit --name alpine2 --network alpine-net alpine ash
docker run -dit --name alpine3 alpine ash
docker exec alpine1 ping -c 2 alpine2
docker exec alpine1 ping -c 2 alpine3

From alpine1, you can't connect to alpine3, because it's on a different network Source 5সোর্স 5. The tutorial's run printed these two lines, among others, and the second docker exec exited with 1:

2 packets transmitted, 2 packets received, 0% packet loss
ping: bad address 'alpine3'

5. Look at what the containers use. By default, a container has no resource constraints Source 10সোর্স 10. -m sets the maximum amount of memory the container can use Source 10সোর্স 10. docker stats displays a live stream of container resource usage statistics; --no-stream only pulls the first result Source 8সোর্স 8. docker system df shows Docker disk usage Source 11সোর্স 11:

docker run -dit --name alpine4 -m 64m alpine ash
docker stats --no-stream alpine1 alpine4
docker system df

The tutorial's run printed this for docker stats:

CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O         BLOCK I/O   PIDS
59221f342cc3   alpine1   0.00%     536KiB / 30.16GiB   0.00%     9.87kB / 406B   0B / 0B     1
2f4caa24caf0   alpine4   0.00%     528KiB / 64MiB      0.81%     644B / 84B      0B / 0B     1

The limit of alpine1, which has no -m, was the memory of the whole host (30.16GiB); the limit of alpine4 was 64MiB. docker system df printed one row each for images, containers, local volumes, and build cache, with the columns TOTAL, ACTIVE, SIZE, and RECLAIMABLE.

6. Clean up. Docker's tutorial stops and removes the containers, then removes the network Source 5সোর্স 5. docker volume rm removes the volume Source 2সোর্স 2:

docker container stop alpine1 alpine2 alpine3 alpine4
docker container rm alpine1 alpine2 alpine3 alpine4
docker network rm alpine-net
docker volume rm myvol2
rm -rf reports typo-dir result-copy.txt

In the tutorial's run, the last line worked without sudo.

সহজ English

The tutorial ran these steps on 2026-11-16 with Docker Engine 29.9.3 on Linux, as a user in the docker group. The file contents (run 1: 12 passed, 1 passed) are the tutorial's own sample data. IDs, sizes, and paths differ on your machine.

1. Keep a result in a volume, and copy it out. If you start a container with a volume that does not exist yet, Docker makes the volume for you; the first command is Docker's own example, on one line Source 2সোর্স 2. docker exec runs a new command in a running container Source 6সোর্স 6. The command must be a program, and a chained or quoted command does not work, so the second command runs in sh -c, as Docker's example does Source 6সোর্স 6. docker cp works with a running or a stopped container Source 7সোর্স 7:

docker run -d --name devtest --mount source=myvol2,target=/app nginx:latest
docker exec devtest sh -c 'echo "run 1: 12 passed" > /app/result.txt'
docker container stop devtest
docker cp devtest:/app/result.txt ./result-copy.txt
docker container rm devtest
docker run --rm --mount source=myvol2,target=/app alpine cat /app/result.txt

In the tutorial's run, docker cp copied the file out of the stopped container, and ls -l result-copy.txt showed the user who ran docker cp as its owner. The last command starts a new container with the same volume. It printed run 1: 12 passed, the line that the removed container had written.

2. Write a report to the host. A bind mount puts a folder of the host into the container, and by default the container can write to it Source 3সোর্স 3:

mkdir reports
docker run --rm --mount type=bind,src="$(pwd)"/reports,dst=/reports alpine sh -c 'echo "1 passed" > /reports/result.txt'
cat reports/result.txt

In the tutorial's run, cat printed 1 passed, and ls -l reports showed that result.txt belonged to root, not to the user who ran the command.

3. See what a wrong path does. By default, --mount does not make a folder that is missing on the host; it stops with an error Source 3সোর্স 3. With --volume (-v), Docker makes the missing folder on the host for you, and it is always a folder Source 3সোর্স 3:

docker run --rm --mount type=bind,src="$(pwd)"/no-such-dir,dst=/reports alpine ls /reports
docker run --rm -v "$(pwd)"/typo-dir:/reports alpine ls -la /reports

In the tutorial's run, the first command printed docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: with the full path, and exited with code 125. The second one exited with 0: it made typo-dir on the host, owned by root, and ls -la in the container listed an empty /reports.

4. Let containers find each other by name. These commands follow Docker's tutorial on bridge networks that you create, with three containers instead of its four; the -dit flags mean detached, interactive, and with a TTY Source 5সোর্স 5. Docker's tutorial attaches to alpine1 to run the ping Source 5সোর্স 5; here, docker exec runs it:

docker network create --driver bridge alpine-net
docker run -dit --name alpine1 --network alpine-net alpine ash
docker run -dit --name alpine2 --network alpine-net alpine ash
docker run -dit --name alpine3 alpine ash
docker exec alpine1 ping -c 2 alpine2
docker exec alpine1 ping -c 2 alpine3

From alpine1, you cannot reach alpine3, because it is on another network Source 5সোর্স 5. The tutorial's run printed these two lines, among others, and the second docker exec exited with 1:

2 packets transmitted, 2 packets received, 0% packet loss
ping: bad address 'alpine3'

5. Look at what the containers use. By default, a container has no limits Source 10সোর্স 10. -m sets the most memory that the container can use Source 10সোর্স 10. docker stats shows a live stream of how much the containers use; --no-stream shows only the first result Source 8সোর্স 8. docker system df shows how much disk Docker uses Source 11সোর্স 11:

docker run -dit --name alpine4 -m 64m alpine ash
docker stats --no-stream alpine1 alpine4
docker system df

The tutorial's run printed this for docker stats:

CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O         BLOCK I/O   PIDS
59221f342cc3   alpine1   0.00%     536KiB / 30.16GiB   0.00%     9.87kB / 406B   0B / 0B     1
2f4caa24caf0   alpine4   0.00%     528KiB / 64MiB      0.81%     644B / 84B      0B / 0B     1

The limit of alpine1, which has no -m, was the memory of the whole host (30.16GiB); the limit of alpine4 was 64MiB. docker system df printed one row each for images, containers, local volumes, and build cache, with the columns TOTAL, ACTIVE, SIZE, and RECLAIMABLE.

6. Clean up. Docker's tutorial stops and removes the containers, then removes the network Source 5সোর্স 5. docker volume rm removes the volume Source 2সোর্স 2:

docker container stop alpine1 alpine2 alpine3 alpine4
docker container rm alpine1 alpine2 alpine3 alpine4
docker network rm alpine-net
docker volume rm myvol2
rm -rf reports typo-dir result-copy.txt

In the tutorial's run, the last line worked without sudo.

বাংলা ব্যাখ্যা

টিউটোরিয়াল এই ধাপগুলো 2026-11-16 তারিখে Linux-এ Docker Engine 29.9.3 দিয়ে, docker group-এর একজন user হিসেবে চালিয়েছে। file-এর লেখা (run 1: 12 passed, 1 passed) টিউটোরিয়ালের নিজের নমুনা data। ID, size আর path আপনার machine-এ আলাদা হবে।

১. একটা ফল volume-এ রাখুন, আর বের করে আনুন। এখনো নেই এমন volume দিয়ে container চালু করলে Docker আপনার জন্য volume তৈরি করে দেয়; প্রথম command-টা Docker-এর নিজের উদাহরণ, এক লাইনে লেখা Source 2সোর্স 2। docker exec একটা চলমান container-এ নতুন command চালায় Source 6সোর্স 6। command-টা অবশ্যই একটা executable হতে হবে, chained বা quoted command কাজ করে না, তাই দ্বিতীয় command-টা sh -c-এর ভেতরে চলে, Docker-এর উদাহরণের মতোই Source 6সোর্স 6। docker cp চলমান বা থেমে থাকা, দুই ধরনের container-এর সাথেই কাজ করে Source 7সোর্স 7:

docker run -d --name devtest --mount source=myvol2,target=/app nginx:latest
docker exec devtest sh -c 'echo "run 1: 12 passed" > /app/result.txt'
docker container stop devtest
docker cp devtest:/app/result.txt ./result-copy.txt
docker container rm devtest
docker run --rm --mount source=myvol2,target=/app alpine cat /app/result.txt

টিউটোরিয়ালের run-এ docker cp থেমে থাকা container থেকে file-টা copy করেছে, আর ls -l result-copy.txt দেখিয়েছে এর মালিক সেই user, যিনি docker cp চালিয়েছেন। শেষ command একই volume দিয়ে একটা নতুন container চালু করে। এটা run 1: 12 passed print করেছে, যে লাইন মুছে ফেলা container লিখেছিল।

২. host-এ একটা report লিখুন। bind mount host-এর একটা folder container-এ এনে দেয়, আর default-ভাবে container তাতে লিখতে পারে Source 3সোর্স 3:

mkdir reports
docker run --rm --mount type=bind,src="$(pwd)"/reports,dst=/reports alpine sh -c 'echo "1 passed" > /reports/result.txt'
cat reports/result.txt

টিউটোরিয়ালের run-এ cat print করেছে 1 passed, আর ls -l reports দেখিয়েছে result.txt-এর মালিক root, command চালানো user নন।

৩. ভুল path দিলে কী হয়, দেখুন। default-ভাবে host-এ নেই এমন directory --mount তৈরি করে না; error দেয় Source 3সোর্স 3। --volume (-v) দিলে Docker host-এ না থাকা directory আপনার জন্য তৈরি করে, আর সেটা সবসময় directory হিসেবেই তৈরি হয় Source 3সোর্স 3:

docker run --rm --mount type=bind,src="$(pwd)"/no-such-dir,dst=/reports alpine ls /reports
docker run --rm -v "$(pwd)"/typo-dir:/reports alpine ls -la /reports

টিউটোরিয়ালের run-এ প্রথম command পুরো path-সহ docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: print করেছে, আর exit code 125 দিয়ে শেষ হয়েছে। দ্বিতীয়টা 0 দিয়ে শেষ হয়েছে: host-এ root-এর মালিকানায় typo-dir তৈরি করেছে, আর container-এর ভেতরে ls -la একটা খালি /reports দেখিয়েছে।

৪. container-গুলোকে নাম দিয়ে একে অপরকে খুঁজে পেতে দিন। এই command-গুলো user-defined bridge network নিয়ে Docker-এর tutorial অনুসরণ করে, তবে চারটার বদলে তিনটা container দিয়ে; -dit flag মানে detached, interactive আর TTY-সহ Source 5সোর্স 5। Docker-এর tutorial ping চালাতে alpine1-এ attach করে Source 5সোর্স 5; এখানে docker exec সেটা চালায়:

docker network create --driver bridge alpine-net
docker run -dit --name alpine1 --network alpine-net alpine ash
docker run -dit --name alpine2 --network alpine-net alpine ash
docker run -dit --name alpine3 alpine ash
docker exec alpine1 ping -c 2 alpine2
docker exec alpine1 ping -c 2 alpine3

alpine1 থেকে alpine3-এ যুক্ত হওয়া যায় না, কারণ সেটা অন্য network-এ Source 5সোর্স 5। টিউটোরিয়ালের run অন্য লাইনের সাথে এই দুটো লাইন print করেছে, আর দ্বিতীয় docker exec exit code 1 দিয়ে শেষ হয়েছে:

2 packets transmitted, 2 packets received, 0% packet loss
ping: bad address 'alpine3'

৫. container-গুলো কী ব্যবহার করছে, দেখুন। default-ভাবে একটা container-এর কোনো resource constraint নেই Source 10সোর্স 10। container সর্বোচ্চ কত memory ব্যবহার করতে পারবে, -m তা ঠিক করে Source 10সোর্স 10। docker stats container-এর resource ব্যবহারের একটা live stream দেখায়; --no-stream শুধু প্রথম ফলটা আনে Source 8সোর্স 8। docker system df Docker-এর disk ব্যবহার দেখায় Source 11সোর্স 11:

docker run -dit --name alpine4 -m 64m alpine ash
docker stats --no-stream alpine1 alpine4
docker system df

টিউটোরিয়ালের run-এ docker stats এটা print করেছে:

CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O         BLOCK I/O   PIDS
59221f342cc3   alpine1   0.00%     536KiB / 30.16GiB   0.00%     9.87kB / 406B   0B / 0B     1
2f4caa24caf0   alpine4   0.00%     528KiB / 64MiB      0.81%     644B / 84B      0B / 0B     1

-m ছাড়া চালানো alpine1-এর limit ছিল পুরো host-এর memory (30.16GiB); alpine4-এর limit ছিল 64MiB। docker system df image, container, local volume আর build cache-এর জন্য একটা করে row print করেছে, TOTAL, ACTIVE, SIZE আর RECLAIMABLE column-সহ।

৬. পরিষ্কার করুন। Docker-এর tutorial container-গুলো থামিয়ে মুছে দেয়, তারপর network মুছে দেয় Source 5সোর্স 5। docker volume rm volume-টা মুছে দেয় Source 2সোর্স 2:

docker container stop alpine1 alpine2 alpine3 alpine4
docker container rm alpine1 alpine2 alpine3 alpine4
docker network rm alpine-net
docker volume rm myvol2
rm -rf reports typo-dir result-copy.txt

টিউটোরিয়ালের run-এ শেষ লাইনটা sudo ছাড়াই কাজ করেছে।

How a tester uses it

Prepare test data once. New volumes can have their content pre-populated by a container or build Source 2সোর্স 2. Mounting an empty volume over files copies those files into the volume, which is a good way to pre-populate data that another container needs Source 2সোর্স 2. Volumes can be more safely shared among multiple containers Source 2সোর্স 2.

Use fast, throwaway data. If your container generates non-persistent state data, a tmpfs mount avoids storing the data anywhere permanently, and increases the container's performance by avoiding writing into the container's writable layer Source 2সোর্স 2. Unlike volumes and bind mounts, you can't share tmpfs mounts between containers, and tmpfs is only available if you're running Docker on Linux Source 4সোর্স 4.

Get the evidence out. docker cp copies files or folders between a container and the local filesystem Source 7সোর্স 7. The container can be a running or stopped container Source 7সোর্স 7. Files copied to the local machine are created with the UID:GID of the user which invoked the docker cp command Source 7সোর্স 7:

docker cp <container>:/path/in/container/report.txt ./report.txt

Reach services by name. Put the application and the test container on one user-defined network, so that DNS resolves the container names Source 5সোর্স 5. Give the containers names, because automatic service discovery does not resolve default generated names Source 5সোর্স 5.

Know where the logs go. By default, docker logs shows the command's STDOUT and STDERR Source 9সোর্স 9. A web server or a database may send its output to log files instead Source 9সোর্স 9. For example, the official nginx image creates symbolic links from its log files to /dev/stdout and /dev/stderr Source 9সোর্স 9.

Test with limits. By default, a container has no resource constraints and can use as much of a given resource as the host's kernel scheduler allows Source 10সোর্স 10. -m (--memory) sets the maximum amount of memory the container can use, and --cpus how much of the available CPU resources it can use Source 10সোর্স 10. On Linux hosts, when there isn't enough memory for important system functions, the kernel throws an Out Of Memory Exception and starts killing processes Source 10সোর্স 10. Docker's advice is to perform tests to understand the memory requirements of your application before placing it into production Source 10সোর্স 10.

সহজ English

Prepare test data once. A new volume can be filled with data by a container or a build Source 2সোর্স 2. If you mount an empty volume over files, Docker copies those files into the volume; that is a good way to prepare data that another container needs Source 2সোর্স 2. Volumes are safer to share between many containers Source 2সোর্স 2.

Use fast, throwaway data. For data that does not need to last, a tmpfs mount keeps it from being stored anywhere for good, and makes the container faster, because it does not write to the container's writable layer Source 2সোর্স 2. Unlike volumes and bind mounts, a tmpfs mount cannot be shared between containers, and tmpfs works only when Docker runs on Linux Source 4সোর্স 4.

Get the evidence out. docker cp copies files or folders between a container and the local file system Source 7সোর্স 7. The container can be running or stopped Source 7সোর্স 7. Files copied to the local machine belong to the user who ran docker cp Source 7সোর্স 7:

docker cp <container>:/path/in/container/report.txt ./report.txt

Reach services by name. Put the app and the test container on one network that you create, so that DNS finds the container names Source 5সোর্স 5. Give the containers names, because automatic discovery does not work with the names that Docker makes up Source 5সোর্স 5.

Know where the logs go. By default, docker logs shows what the command writes to STDOUT and STDERR Source 9সোর্স 9. A web server or a database may write to log files instead Source 9সোর্স 9. For example, the official nginx image links its log files to /dev/stdout and /dev/stderr Source 9সোর্স 9.

Test with limits. By default, a container has no limits, and can use as much of a resource as the host's kernel allows Source 10সোর্স 10. -m (--memory) sets the most memory that the container can use, and --cpus how much of the CPU it can use Source 10সোর্স 10. On Linux, when there is not enough memory for important system work, the kernel raises an Out Of Memory Exception and starts killing processes Source 10সোর্স 10. Docker advises you to test how much memory your application needs before it goes to production Source 10সোর্স 10.

বাংলা ব্যাখ্যা

test data একবারেই তৈরি করুন। নতুন volume-এর বিষয়বস্তু একটা container বা build আগে থেকে ভরে দিতে পারে Source 2সোর্স 2। file-এর ওপর একটা খালি volume mount করলে সেই file-গুলো volume-এ copy হয়, আর অন্য container-এর দরকারি data আগে থেকে ভরে রাখার এটা একটা ভালো উপায় Source 2সোর্স 2। volume একাধিক container-এর মধ্যে বেশি নিরাপদে share করা যায় Source 2সোর্স 2।

দ্রুত, ফেলে দেওয়ার মতো data ব্যবহার করুন। container যদি non-persistent state data তৈরি করে, tmpfs mount সেই data কোথাও স্থায়ীভাবে রাখে না, আর container-এর writable layer-এ লেখা এড়িয়ে container-এর performance বাড়ায় Source 2সোর্স 2। volume আর bind mount-এর মতো tmpfs mount container-গুলোর মধ্যে share করা যায় না, আর tmpfs শুধু Linux-এ Docker চালালেই পাওয়া যায় Source 4সোর্স 4।

প্রমাণ বের করে আনুন। docker cp একটা container আর local filesystem-এর মধ্যে file বা folder copy করে Source 7সোর্স 7। container চলমান বা থেমে থাকা, দুটোই হতে পারে Source 7সোর্স 7। local machine-এ copy হওয়া file তৈরি হয় সেই user-এর UID:GID দিয়ে, যিনি docker cp চালিয়েছেন Source 7সোর্স 7:

docker cp <container>:/path/in/container/report.txt ./report.txt

নাম দিয়ে service-এ পৌঁছান। application আর test container একটা user-defined network-এ রাখুন, যাতে DNS container-এর নাম resolve করে Source 5সোর্স 5। container-গুলোকে নাম দিন, কারণ automatic service discovery Docker-এর নিজে বানানো default নাম resolve করে না Source 5সোর্স 5।

log কোথায় যায়, জানুন। default-ভাবে docker logs command-এর STDOUT আর STDERR দেখায় Source 9সোর্স 9। একটা web server বা database তার output log file-এ পাঠাতে পারে Source 9সোর্স 9। যেমন, official nginx image তার log file থেকে /dev/stdout আর /dev/stderr-এ symbolic link তৈরি করে Source 9সোর্স 9।

সীমা দিয়ে test করুন। default-ভাবে একটা container-এর কোনো resource constraint নেই, আর host-এর kernel scheduler যতটা দেয়, ততটা resource ব্যবহার করতে পারে Source 10সোর্স 10। -m (--memory) container সর্বোচ্চ কত memory ব্যবহার করতে পারবে তা ঠিক করে, আর --cpus ঠিক করে উপলব্ধ CPU resource-এর কতটা ব্যবহার করতে পারবে Source 10সোর্স 10। Linux host-এ গুরুত্বপূর্ণ system কাজের জন্য যথেষ্ট memory না থাকলে kernel একটা Out Of Memory Exception দেয় আর process বন্ধ করতে শুরু করে Source 10সোর্স 10। Docker-এর পরামর্শ: production-এ নেওয়ার আগে test করে application-এর memory চাহিদা বুঝে নিন Source 10সোর্স 10।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • -v path-এ বানান ভুল। --volume দিলে Docker host-এ না থাকা directory আপনার জন্য তৈরি করে Source 3সোর্স 3। টিউটোরিয়ালের run-এর ধাপ ৩-এ container তখন একটা খালি folder দেখেছে। --mount ব্যবহার করুন, source path না থাকলে এটা error দেয় Source 3সোর্স 3।
  • image-এর দরকারি file-এর ওপর mount করা। আগে থেকে থাকা file-গুলো mount-এর আড়ালে ঢাকা পড়ে Source 2সোর্স 2। container-এ mount সরিয়ে ঢাকা file আবার দেখার সহজ কোনো উপায় নেই Source 2সোর্স 2।
  • নিজের কাজের writable bind mount। default-ভাবে bind mount-এর host-এর file-এ লেখার অধিকার থাকে Source 3সোর্স 3। container-এর শুধু পড়ার দরকার হলে readonly (ro) যোগ করুন Source 3সোর্স 3।
  • default bridge-এ নাম কাজ করবে ভাবা। default bridge network-এ container-গুলো নাম দিয়ে একে অপরকে খুঁজে পায় না Source 5সোর্স 5।
  • tmpfs-এর data থেকে যাবে ভাবা। container থামলে tmpfs mount সরিয়ে ফেলা হয়, আর সেখানে লেখা file টিকে থাকে না Source 4সোর্স 4।
  • অব্যবহৃত volume জমতে দেওয়া। কোনো চলমান container ব্যবহার করছে না এমন volume নিজে থেকে মোছে না Source 2সোর্স 2। docker volume prune অব্যবহৃত volume মুছে দেয় Source 2সোর্স 2।
  • shared machine-এ prune করা। docker system prune সব অব্যবহৃত container, network, image (dangling ও unused দুটোই), অব্যবহৃত build cache, আর চাইলে volume-ও মুছে দেয় Source 12সোর্স 12। কোনো option ছাড়া এর warning-এ থাকে সব থেমে থাকা container, অন্তত একটা container ব্যবহার করছে না এমন সব network, সব dangling image আর অব্যবহৃত build cache Source 12সোর্স 12। --all শুধু dangling নয়, সব অব্যবহৃত image মুছে দেয়, আর --volumes anonymous volume মুছে দেয় Source 12সোর্স 12।

What a tester can check

Tutorial advice

This list is the tutorial's own advice for a tester who runs tests in containers.

  • Ask which volume holds each test database, and how it is reset between test runs.
  • In scripts, use --mount for bind mounts, so that a wrong path fails instead of mounting an empty folder.
  • Mount test code and fixtures read-only when the tests should not change them.
  • Check who owns the files that a container writes to a bind mount; in the tutorial's run, they belonged to root.
  • Give your containers names, and put the app and the tests on one user-defined network.
  • Copy the reports out of a failed container with docker cp before you remove it.
  • Ask before you run docker system prune on a machine that other people use.
  • When a container dies during a load test, check its memory limit.

সহজ English

Tutorial advice

This list is the tutorial's own advice for a tester who runs tests in containers.

  • Ask which volume holds each test database, and how it is reset between test runs.
  • In scripts, use --mount for bind mounts, so that a wrong path fails instead of mounting an empty folder.
  • Mount test code and fixtures read-only when the tests should not change them.
  • Check who owns the files that a container writes to a bind mount; in the tutorial's run, they belonged to root.
  • Give your containers names, and put the app and the tests on one network that you create.
  • Copy the reports out of a failed container with docker cp before you remove it.
  • Ask before you run docker system prune on a machine that other people use.
  • When a container dies during a load test, check its memory limit.

বাংলা ব্যাখ্যা

Tutorial advice

এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, container-এ test চালানো একজন tester-এর জন্য।

  • জিজ্ঞেস করুন কোন volume-এ কোন test database থাকে, আর দুই test run-এর মাঝে সেটা কীভাবে reset হয়।
  • script-এ bind mount-এর জন্য --mount ব্যবহার করুন, যাতে ভুল path দিলে খালি folder mount না হয়ে ফেল করে।
  • test যেন code আর fixture না বদলায়, তখন সেগুলো read-only mount করুন।
  • container bind mount-এ যে file লেখে, তার মালিক কে, দেখুন; টিউটোরিয়ালের run-এ মালিক ছিল root।
  • container-কে নাম দিন, আর app ও test একটা user-defined network-এ রাখুন।
  • ফেল করা container মোছার আগে docker cp দিয়ে report বের করে আনুন।
  • অন্যরাও ব্যবহার করে এমন machine-এ docker system prune চালানোর আগে জিজ্ঞেস করুন।
  • load test-এর সময় একটা container বন্ধ হয়ে গেলে তার memory limit দেখুন।

Key words

TermMeaning
Writable container layerWhere the files created inside a container are stored; its data doesn't persist when the container is destroyed
VolumeA persistent data store for containers, created and managed by Docker
Anonymous volumeA volume with a random name; it stays after its container is removed, unless the container was started with --rm
Bind mountA file or directory on the host machine mounted into a container; writable by default
tmpfs mountA temporary mount in the host memory, removed when the container stops
--mountThe preferred, more explicit flag to mount; for a bind mount it errors when the source path doesn't exist
--volume (-v)The short flag to mount; for a bind mount it creates a missing host directory
readonly (ro)The option that prevents the container from writing to the mount
Default bridge networkThe network of containers started without --network; no name resolution
User-defined bridge networkA network made with docker network create; containers resolve each other by name
docker cpCopies files or folders between a container, running or stopped, and the local filesystem
docker statsDisplays a live stream of container resource usage statistics
-m (--memory)The maximum amount of memory that a container can use
docker system pruneRemoves stopped containers, unused networks, dangling images, and unused build cache; --all and --volumes remove more

Reels on this topicএই টপিকের রিলস

Short videos from other creators, picked for this topic. They are not part of this page's fact-checked text. Nothing loads from YouTube until you press Play.অন্য ক্রিয়েটরদের বানানো ছোট ভিডিও, এই টপিকের জন্য বাছাই করা। এগুলো এই পেজের ফ্যাক্ট-চেক করা লেখার অংশ নয়। চালান বাটন চাপার আগে YouTube থেকে কিছুই লোড হয় না।

Show 4 more reelsআরও 4টি রিল দেখান
  1. [1]
    Storage

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  2. [2]
    Volumes

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  3. [3]
    Bind mounts

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  4. [4]
    tmpfs mounts

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  5. [5]
    Bridge network driver

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  6. [6]
    docker container exec

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  7. [7]
    docker container cp

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  8. [8]
    docker container stats

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  9. [9]
    View container logs

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  10. [10]
    Resource constraints

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  11. [11]
    docker system df

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16

  12. [12]
    docker system prune

    Docker Docs · accessed 2026-11-16দেখা হয়েছে: 2026-11-16