Back to list
Dockerを学ぶ:Dockerfile、.dockerignoreとポートマッピング
Learning Docker: Dockerfiles, .dockerignore, and Port Mapping 🐳
Translated: 2026/3/7 11:00:22
Japanese Translation
こんにちは!皆さんにこの週の私の学びを更新します。ついにDockerファイルの二つを実際に使ってきました。それは基本的にはプロジェクトの指示書です。ここでは必要なすべてのコマンドを開発するのですから、このファイルは私たちがカスタムイメージを構築するために使用します。
Original Content
Hey everyone! Here’s a quick update on what I learned last week. I finally got hands-on with two essential Docker files: the Dockerfile and .dockerignore.
First up, let's talk about the .dockerignore file. If you've used Git, this works exactly like .gitignore. When we build an image, this file prevents Docker from copying over unnecessary files and folders, which helps keep our final image clean and lightweight.
Next, I created the Dockerfile. This is basically the instruction manual for your project. We write down all the necessary commands in here, and Docker uses this file as the blueprint to build our custom image.
After building the image, it was time to run it. This is where I learned how port mapping works. Port mapping is simply telling the Docker container, "Hey, forward your internal project port to this specific port on my local system."
In my setup below, I mapped the ports so my project runs on port 5173 inside the container's terminal, but I can actually access it in my local browser using port 3200.