Sometimes it's just annoying to build a docker image, then run the container from that image. Even if it's only two 2 commands, it can become very annoying when done repetitively.
Luckily, there is a command to run a container directly from a Dockerfile.
docker run $(docker build -q .)
The -q
option suppresses the build output and prints image ID on success.
If you have to expose a port for your container, you can just add the -p
flag to your command, and there you go!
docker run -p 8000:8000 $(docker build -q . -t image-name:tag)
^ ^
| |
| 'port in your container'
|
'port in your computer'
Author : Kevin Kouomeu
I hope you enjoyed reading this, and I'm curious to hear if this tutorial helped you. Please let me know your thoughts below in the comments section 💬.
My goal with this blog is mainly to create helpful content for
Connect with me here LinkedIn • Twitter • Instagram • GitHub or Medium
I hope you enjoyed reading this, and I'm curious to hear if this tutorial helped you. Please let me know your thoughts below in the comments section 💬.
My goal with this blog is mainly to create helpful content for
Java
and Javascript
web devs, if you want to discuss a specific topic related to the programming world, you can reach me on my social platforms. Connect with me here LinkedIn • Twitter • Instagram • GitHub or Medium