-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBasic Docker Commands
22 lines (17 loc) · 1.44 KB
/
Basic Docker Commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Once you are all set up with the Docker CE, here's where to get started.
$ docker ps ---> lists the running containers
$ docker ps -a ---> lists all the containers (which are running and exited as well)
$ docker images ---> lists the images that are pulled
$ docker pull <image_name> ---> To pull the image of the container from docker hub
$ docker run <image_name> ---> This starts the container
$ docker stop <container_name> ---> This stops the container
$ docker run -d <image_name> ---> The container starts running in the background
$ docker attach <container_Id> ---> The background container comes into the forefront
$ docker run -d <container_name> sleep 20 ---> The container starts running for 20 seconds without exiting
$ docker rm <container_name> ---> This is to remove containers, you cna just type in the first two characters of the container ID instead of the whole container ID
$ docker exec <container_name> cat/etc/host*release* ---> To execute a command on a container that is already running
$ docker rmi <image_id> ---> To remove image/images
##Volume Mapping
$ docker run -p 80:8080 -v destination path: arrival path <image_name> ---> 80: Docker host port, 8080: Port on which application runs, path where the data will be saved even if the container is killed
$ docker run Ubuntu:17.04 ---> This is to get a particular version instead of the default version
## For a force stop of a container the ext code would be Exited (137)