# Specify tag
docker build -t mycontainer .
# Specify dockerfile
docker build -f Dockerfile .
docker run mycontainer
# With environment variable
docker run --env MYVAR=true mycontainer
# With environment file
docker run --env-file .env mycontainer
# With custom command
docker run mycontainer sh -c "echo 'hello world'"
# Enter a shell inside the container (commands below are equivalent)
docker run -it mycontainer /bin/bash
docker run -it --entrypoint "/bin/bash" mycontainer
# Mount the current directory
docker run -v $(pwd):/home/src -it mycontainer /bin/bash
# Get access to network control
docker run --privileged --net=host -it mycontainer /bin/bash
# Get access to systemd control (not recommended though)
docker run --privileged -v /bin/systemctl:/bin/systemctl -v /run/systemd/system:/run/systemd/system -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket -v /sys/fs/cgroup:/sys/fs/cgroup -it mycontainer /bin/bash