Docker

My docker commands

Start docker process:

service docker start

Docker process status:

service docker status

Stop docker process:

service docker stop

List all images:

docker images

Create a container from an image:

Interactive Mode:

docker run -it <image name>:<tag>

<tag> is optional, latest tag will be taken if not provided

With tag: docker run -it elasticsearch:latest
Without tag: docker run -it elasticsearch

Detached Mode:

docker run -d <image name>:<tag>

With tag: docker run -d elasticsearch:latest
Without tag: docker run -d elasticsearch

Expose port with the host:

docker run -p <host_port>:<container_port> <image name>

docker run -d -p 9200:9200 -p 9300:9300 elasticsearch

List all containers:

docker ps -a

List only running containers:

docker ps

Start a docker container:

docker start <image id/name>

docker start 42e175dd9630

Stop a docker container:

docker stop <container id/name>

docker stop 42e175dd9630

Cloning a container:

docker commit <existing_container_id/name> <new_container_name>

docker commit elasticsearch-latest elastic-logz

Execute Command:

docker exec <docker container id/name> <command>

docker exec 42e175dd9630 ls -ltrh

Execute Command interactive:

docker exec -it <docker container id/name> <command>

Get terminal access: docker exec -it 42e175dd9630 bash

Get bash as root user:

docker exec -it –user root <container id/name> bash

docker exec -it --user root 42e175dd9630 bash

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s