Skip to content

Instantly share code, notes, and snippets.

@jayjariwala
Last active June 5, 2020 21:18
Show Gist options
  • Save jayjariwala/1b5f8d57f20e297ef4abd2a3ff75a988 to your computer and use it in GitHub Desktop.
Save jayjariwala/1b5f8d57f20e297ef4abd2a3ff75a988 to your computer and use it in GitHub Desktop.
// docker version
docker --version
// Pull image from docker hub
docker pull wasfeng/whalesy
// Run the pulled image or images already on the local system - Run the container from the image
docker run wasfeng/whalesy
// Stop the running docker container
docker stop NAME(name of the container - assigned by the docker cli)
// List all the running container
docker ps
// List all the container including running and exited
docker ps --all
// remove container permanently
docker rm NAME(name of the container - assigned by the docker cli)
// See the list of available images and their sizes
docker images
// To remove an image that we are no longer using
docker rmi nginx
// Sleep for 5 sec and then exit the container
docker run ubuntu sleep 5
// Execute command on the running container
docker exec NAME cat /etc/hosts
// attached mode
docker run knodeklound/Simple-Webapp
// Run docker in a detached mode
docker run -d kodekloud/simple-webapp
// attach docker again
docker attach a043d
// Run image with specific version(tag)
docker run redis:4.0
// inputs
-- docker doesn't listen std input by default
-- must map standerd input to docker parameter with -i parameter
docker run -i kodekloud/simple-prompt-docker
jay
// port mapping
docker run -p 80:5000 kodekloud/simple-webapp
// volume mapping - map data outside the container
docker run -v /opt/datadir:/var/lib/mysql mysql
// view the container logs
docker logs NAME
// find the environment variable that for a docker container that is running
docker inspect blissful_hopper
// Run docker container with specific name and environment variable
docker run -p 38282:8080 --name blue-app -e APP_COLOR=blue -d kodekloud/simple-webapp
// The Docker Image includes your application code, libraries, configuration file, environment variables and runtime.
## How to create your own image ##
dockerfile
// Build a docker image using the Dockerfile with no tag
docker build -t webapp-color
// Base operating system used by the image ?
Run docker run python:3.6 cat /etc/*release*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment