“Building” an image from the Dockerfile (custom image). Layers

      1. $ docker build --help → shows all build commands
      2. Pretty easy
        1. $ docker build -f <fileName> -t <your username>/<imageName> .
          1. -f → don’t need if named Dockerfile. If not, give actual name here (ie, node.dockerfile would need -f)
          2. -t → short for --tag, name for your custom image
          3. -d → runs process in daemon mode (so console stays free)
          4. . → folder in which Dockerfile exists (. = curr dir)
          5. If don’t have required images already downloaded, FROM statement in Dockerbuild will take some time since it will download all required images first(specified in FROM in Dockerfile)
        2. Every instruction in Dockerbuild leads to an intermediate container being built & cached locally. Future builds will look here and if the intermediate container already exists, will just use it. Layers all these containers & makes image w/ name specified above (<username>/<imageName>). Can build with no cache by adding tag $ docker build --no-cache

-or- $ docker build --no-cache=true

Create and run a container from that image

          1. Remember to assign ip port!

$ docker run -d -p 8080:3000 dougwells/node

          1. -d → daemon mode (keeps console free)
          2. -p → ports external:internal(linux vm)

→ ports host_port:container_port

→ port on OsX:containerPort

→ localhost:8080:localhost:3000

          1. dougwells/node → image name

Note, because we copied over files from ExpressSite on image build, any changes to files inside ExpressSite will NOT be reflected on any container ran off of that image (need to create new image

results matching ""

    No results matching ""