Docker Notes
This post is to archive some commonly used docker commands.
Build
Command
Build an image.
1 | # build |
Dockerfile
Dockerfile is the ‘script’ to build the image.
1 | # Indicate an image based on which to build the image. |
Run
Run an image
1 | $ docker run -dit --net=host --restart=always --privileged \ |
--net=host
Automatically map all ports.--restart=always
Restart the container when docker restarts.-v <host_path>:<container_path>
Bind mount a volume. You can bind your code dir to a container and build your code inside a container!
Exec
Execuate some command upon a container, usualy a shell.
1 | $ docker exec -it <container> bash |
Miscellaneous
1 | # stop a container |