docker run docker run --name <container_name> container_name # Run a container with an alias docker run --rm # Remove the container after stop docker rename <old_name> <new_name>
docker run --memory 4m # Minimum RAM needed for docker = 4MB docker run --memory 1g docker run --memory="100m" --cpus=0.5 docker run --it # Run in the interactive mode exit # Exit interactive mode
Specify the command that you want the container to run and detach the container to run in the background
docker run --name <container_name> [--detach | -d ] <image_name> tail -f <command_to_overwrite>
docker exec -it <container_name> <sub-process_to_execute> docker exect <container_name> ps -ef # Show processes in a container ps -aux # Check what is happenning inside a container
docker stop <container_name> # Stop a container docker rm <container_name | container_ID> # Remove a container that is not running docker rm -f <container_name | container_ID> # Remove a container that is running docker container prune # Remove all stopped containers docker rm -f $(docker ps -aq) # Remove all containers (on & off) docker kill <container_name>
docker inspect --format '{{.State.Pid}}' <container_name> kill -9 <process_ID> | docker stop <process_ID | process_name>
docker cp <local_target_path> : docker cp .gitignore mongodb:/home/docker/
docker cp :<target_path> <local_destiny> docker cp mongodb:/home/docker from_mongo_container