Skip to content

Docker Commands

clydeu edited this page Jun 17, 2019 · 5 revisions

Build image

docker build -t <name>:<tag> .

Mount directory to container

Pre-requisite:

  • Make sure host drive is shared by going to docker settings -> Shared drives

docker container run -d -it --name <container name> -p <host port>:<container port> --mount type=bind,source="<host directory>",target=<target directory> <image name>

When using Windows, make sure host directory path has forward slash instead of back slash. e.g. D:/path/to/mount/directory

Create docker containter

docker container run -d -it --name <container name> -p <host port>:<container port> <image name>

Use -P flag to automatically map the ports

Execute bash into Docker container

docker exec -i -t <container name/id> /bin/bash

Explore Docker image contents

docker run -it <image name> sh

For images with an entry point:

docker run -it --entrypoint sh <image name>

Docker image build history (steps)

docker image history --no-trunc <image name> > image_history

Clone this wiki locally