Giter Club home page Giter Club logo

getting-started-docker's Introduction

Dockerfile

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Dockerfile Instructions

FROM        node:alpine
LABEL       author="Manh Tan"
ENV         NODE_ENV=production
WORKDIR     /var/www
COPY        . .
RUN         npm install
EXPOSE      3000
ENTRYPOINT  ["node", "server.js"]

Building a Custom Image

docker build -t <name> .

# Using Registry Name, Image Name and Tag
docker build -t <registry>/<name>:<tag>

Deploy an Image to Docker Hub

docker push <user_name>/<image_name>:<tag>

Running a Container

docker run -p <externalPort>:<internalPort> <imageName>

Images, Containers and File Layers

Using docker logs to view

docker logs <container_id>

Creating a Container Volumn

docker run -p <ports> -v $(pwd)/var/www/logs <imageToRun>

Key docker network Commands

docker network create
docker network ls
docker network rm [network]

# Running a database container in a network
docker run -d --net=isolated_network --name=mongodb mongo

docker run -d -p 3000:3000 -net=isolated_network --name=nodeapp imageName

Using docker exec to Shell into a container

docker exec -it <containerId> sh

Docker Compose Features

  • Start, stop and rebuild services
  • View the status of running services
  • Stream the log output of running services
  • Run a one-off command on a service

Using Docker Compose Commands

docker-compose build
docker-compose up
docker-compose down

YAML Fundamentals

  • YAML files are composed of maps and lists
  • Identation matters
  • Alway use spaces
  • Maps:
    • name: value pars
    • Map can contains other maps for more complex data structures
  • Lists:
    • Sequence of items
    • Multiple maps can be defined in a list

Key Service Configuration Options

  • build
  • environment
  • image
  • networks
  • ports
  • volumes

getting-started-docker's People

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.