Git Product home page Git Product logo

docker's Introduction

create a docker container from a dockerhub image

docker container run -it -p 80:80 nginx

-> here container is the management command for docker(you can find all in typing docker in terminal)

-> run is a subcommand(again find all by typing docker in terminal)

-> -it is another subcommand running the container in a interactive mode ..it will show log straight in the terminal after container runs and stables. And -d is for running the container is detached mode. so -d will run the container in the background and will not show logs straight ahead

docker container run -it -p 80:80 nginx

-> -p is a tag to map the port, the port on the left side of the : is your computers port and the port on the right side is the port the container and these two ports maintains a tcp connection. So any request coming from your computer 80 port will be forwarded to containers 80 port

-> the last nginx is the image in dockerhub that it pulls from and builds a container...remember each container is built from a image that means you can run several container from a image. So, there can be multiple instances (container) of a image.

give that a name with --name flag

docker container run -d -p 80:80 --name mynginx nginx

CONTAINER ID   IMAGE     COMMAND                  CREATED             STATUS                      PORTS                NAMES
2d0c0dfe3dd6   nginx     "/docker-entrypoint.…"   5 seconds ago       Up 4 seconds                0.0.0.0:80->80/tcp   mynginx

List docker containers

List running and stopped containers(two ways and ps is the old way)

$: docker container ls -a

$: docker ps -a

List only running containers(two ways and ps is the old way)

$: docker container ls

$: docker ps

List docker images

$: docker images   

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    62d49f9bab67   2 weeks ago   133MB

Delete docker image

$ docker image rm 62d

-> Important Note: Sometimes need to add the -f flag if the image is being used by a container...

Pull a image from docker hub at any time

-> docker pull nginx

get inside a container

docker exec -it <container name> /bin/bash

docker's People

Contributors

riyadzaigirdar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.