Git Product home page Git Product logo

docker-getting-started's Introduction

List of Docker commands

Curated while getting started with Docker

Container level

Build and run app

Log into docker

docker login

Quick test of proper environment set up

docker run hello-world

Build app

docker build -t NAME-OF-APP

Run app

  • docker run -p 4000:80 NAME-OF-APP

    visit http://localhost:4000

  • docker run -p 80:80 USERNAME/REPO:TAG

    visit http://localhost/

Get container info docker ps after running the app, will list port

Can also get port info via docker port CONTAINER-ID or docker port CONTAINER-NAME

Run app in background, in detached mode

docker run -d -p 4000:80 NAME-OF-APP

Stop process

docker stop CONTAINER-ID

Docker image

Look at Docker image registry

docker images

Publish the image

docker push USERNAME/REPO:TAG

Pull and run image from remote repo

docker run -p 4000:80 USERNAME/REPO:TAG

Tag image

docker tag image USERNAME/REPO:TAG

Service level

Run docker-compose.yml

// Copy new/updated docker-compose.yml file before deploying the new/updated version

  • docker-machine scp docker-compose.yml VM-NAME:~

  • docker stack deploy -c docker-compose.yml NAME-OF-APP

    Run docker swarm init once before if it has not been done yet

See list of containers just launched

docker stack ps NAME-OF-APP

Take down the app

docker stack rm NAME-OF-APP

Take down the swarm after the app

docker swarm leave --force

Swarms

Use docker-machine and VirtualBox to create VMS

docker-machine create --driver virtualbox VM-NAME

See how to connect Docker Client to Docker engine running on a particular created VM

docker-machine env VM-NAME

Instruct VM to be a swarm manager

Only a swarm manager can execute Docker commands

docker-machine ssh VM-NAME "docker swarm init"

  • docker-machine ssh is a command that enables sending commands to a specified VM
  • If error with need to use --advertise-addr, then docker-machine ssh VM-NAME "docker swarm init --advertise-addr VM-IP:2377"

docker-machine ls to find IP for appropriate VM-IP;

Specifying port has to be 2377

Join swarm

Add worker to a swarm

Workers are for capacity and are not able to execute Docker commands

docker-machine ssh VM-NAME "docker swarm join --token <token>"

make sure specifying port is 2377

Check nodes in a swarm

docker-machine ssh VM-NAME THEN in the machine, then run 'docker node ls' THEN to exit with command exit

Alternatively, docker-machine ssh VM-NAME "docker node ls"

Leave swarm

docker-machine ssh VM-NAME "docker swarm leave"

Deploy app on a cluster

docker-machine scp docker-compose.yml VM-NAME:~

docker-machine ssh VM-NAME "docker stack deploy -c docker-compose.yml NAME-OF-APP"

Check via docker-machine ssh VM-NAME "docker stack ps NAME-OF-APP"

Access cluster

docker-machine ls

Cleanup

docker-machine ssh VM-NAME "docker stack rm NAME-OF-APP"

Can choose to keep the swarm or remove it

Stacks

Visualizer service

Run docker-machine ls to get IP address of one of nodes

In this version, visualizer runs on port 8080, so visit either IP address at this port.

docker-getting-started's People

Contributors

lingtran avatar

Watchers

 avatar  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.