Docker

Why Docker - container image

  • independent packages
    • avoid version conflicts
  • namespace isolation

    • network isolation, own IP address and no need to worry about port conflicts
  • docker hub, public

    • where do you put

Dockerfile

  • FROM define the base image
    • if we use the same base image, docker will only pull once
    • alpine is the default base image
  • MAINTEAINER
  • ADD take a file/directory from the host machine and adds them to the file system of the container at specified location
  • ENTRYPOINT let the docker container run as executable

Commands

  • docker build - build an image
  • docker run - create container
  • docker ps - see running containers
  • docker tag and docker login then docker push

Build

  • create docker file
    • get the base image
    • get the dependencies (python, make, git...)
    • create app dir
    • copy package.json
    • run npm install
    • bundle your app's source code inside the Docker image, use the COPY instruction:
    • expose port
    • run commands

Run

docker run -p 49160:8080 -d <your username>/node-web-app

Push

#Create a new image from a container change
#docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
docker commit CONTAINER_ID xunrongli/demo-dra:v1

#Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
#docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker tag demo-dra xunrongli/demo-dra
docker push xunrongli/demo-dra

results matching ""

    No results matching ""