Last active
June 24, 2021 18:23
-
-
Save INF800/a18fea3eadc7661bb8135187e04c7eaa to your computer and use it in GitHub Desktop.
Docker commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ======================================================================================== | |
# setup image | |
# ======================================================================================== | |
# download or build image | |
docker build . | |
# ======================================================================================== | |
# setup container | |
# ======================================================================================== | |
# create container (from local container) | |
docker create -t <image-id> | |
# create and start container (without connecting folder, port etc.) | |
docker start <container-id> | |
# create and start container (connecting folder, port etc.) | |
# note: | |
# - using image-id for run and container-id for start | |
# - image-id can be from docker hub as well | |
docker run -it -p <local_port>:<container_port> -v <host_dir>:<container_dir> <image-id> /bin/bash | |
docker start <container-id> | |
# remove container | |
docker rm <container-id> | |
# ======================================================================================== | |
# get into bash | |
# ======================================================================================== | |
# open terminal shell | |
docker exec -it <container-id> /bin/bash | |
# run any random command | |
docker exec -it <container-id> <command> | |
# ======================================================================================== | |
# add gpu | |
# ======================================================================================= | |
docker run --name my_all_gpu_container --gpus all -t nvidia/cuda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment