Skip to content

ljbili/docker-commands

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Docker commands

Docker Version :
docker version

Information of Docker container and images in your docker :
docker info

Cloning Image from Docker Hub :
docker image pull {image_name:veriosn}

  • For cloning tomcat:8.0 image in your docker docker image pull tomcat:8.0

For listing all images in your docker :
docker image ls

For removing Image from Docker : docker image rm {image_name} docker image rm {image_id}

Creating Docker Container :
docker container create --publish {image_file_expose_port:local_machine_port} --name {container_name}

  • For creating tomcat container in your docker docker container create --publish 8082:8080 --name my-tomcat-container tomcat:8.0

For listing all container in your docker :
docker container ls docker container ls -a docker container ps

For starting container in your docker :
docker container start -it {container_name} for interactive mode docker container start -it {container_id} docker container start -d {container_name} for detach mode (running in background)

For executing bash command inside your docker container :
docker contianer exec -it {container_name} bash

  • docker container exec -it my-tomcat-container bash it will list your docker tomcat container your docker as :/usr/local/tomcat

For stoping container in your docker :
docker container stop {container_name}
docker container stop {container_id}

For removing container in your docker :
docker container rm {container_name}
docker container rm {container_id} docker container rm -f {container_name} for force remove container while it is still in process/running

For removing multiple container in your docker :
docker container rm {container_id} {container_id}

Creating image file for your application :
Following code is for creating image file for war which will be deploy in docker tomcat container.
Create a file with name Dockerfile in root directory of your application without any extension and add following lines in it.

# We are extending everything from tomcat:8.0 image ...

FROM tomcat:8.0

MAINTAINER {your_name}  

# COPY {path-to-your-application-war} {path-to-webapps-in-docker-tomcat}  

COPY some-app/target/some-app.war /usr/local/tomcat/webapps/

docker image build -t {your_name/image_name} ./

  • docker image build -t your_name/some-app-image ./
    Now if you list images in your docker docker image ls -a it will contain image that you have just created for your application.

For deploying application image in your docker :
docker container run -it --publish 8081:8080 your_name/some-app-image Your application will be running in docker container.

About

Docker helpful commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published