GithubHelp home page GithubHelp logo

dockernotes's Introduction

Docker Tips and Tricks

This file is a reference for some basic ideas and commands around Docker.

What are images and containers?

Docker images are read-only files that are layered one on top of the other. An image can pull a previous image using a ‘From’ statement. Multiple FROM statements can be used technically, but Docker doesn’t advise this. Layered images pull in all the environmental specifications you need for your container. Docker images are static.

Docker containers are a thin, writable layer on top of the image. You can interact with containers, change files around, write new information, etc in a container. An example is running a container off a Postgres image and then saving the info in the database. That data will persist as long as the container is running.

Image related commands

Build an image called "imageName" from Dockerfile in current folder: docker build -t imageName .

Look at history of an image: docker history {{ImageID#}}

Container related commands

Example of running an image of a server: docker run -it -p 8080:8080 {{ImageID#}}

Here we have:
-it makes it run interactive
-p assigns ports, which is set up as VM_Port:Local_Machine_Port

Other useful tags:
-d run container in detatched state from terminal
-e set enviroment variables

Docker Compose

Docker compose is a useful way to build images and run containers all in one command. To run docker-compose, you must write a docker-compose.yml file. For more info, see Docker's Compose documentation : https://docs.docker.com/compose/compose-file/

Fun Stuff

Reset which docker-machine you are using to "default":
eval "$(docker-machine ip default)"

View list of available VMs on your computer:
docker-machine ls

You can override the commands of the run by adding the desired command to the end of the run command. For example: docker run -it -p 8080:8080 {{ImageID#}} echo hello world

Useful commands:
docker ps : shows all currently running containers
docker ps -a : shows all containers
docker images : shows all loaded images
docker rm [id] : remove a container
docker rmi : remove an image

dockernotes's People

Contributors

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