Docker - Build and Run One-liner
Last Updated on Sat, 12 Nov 2022 03:46:15 GMT - Edit Page
From the path containing the Dockerfile:
docker run --rm $(docker build -q .)
Add other flags if necessary, for example -p 8080:80 to map container port 80 to host port 8080:
docker run --rm -p 8080:80 $(docker build -q .)
Watch out for Dangling Images.
Explanation
Command docker build builds an image from a Dockerfile.
Flag -q (quiet). Output the image ID only. In our case, the image ID is then passed directly to the docker run command.
Path to the Dockerfile. The . is used to specify the current directory.
$ docker build -q .
sha256:018034711c529bcf98bb9683f2cd67f2912caadf3ab8040f5e4f811578b7693f
Command docker run creates and starts a new container.
$ docker run --rm IMAGE-ID
An image ID is required.
Flag --rm deletes the container when it exists.
References
Connected pages
pages sharing a tag or linking to each other
Text version
- How to Fix Your Android Phone Hotspot
- Small Web Directory: Where to Find Independent Websites
- Blogroll
- How to Enable Strict Type Checking in Godot
- TIC-80
- Game Dev Events in Japan
- Designing Games: A Guide to Engineering Experiences – Book Summary and Notes
- Docker - Dangling Images
- AWS Certified Solutions Architect - Associate (SAA-C03) Exam Study Notes
- Sins of Storytelling
- Invisible Ink: A Practical Guide to Build Stories that Resonate – Book Summary and Notes