Created
January 25, 2020 07:48
-
-
Save kudaliar032/b0d32d73c69c04d54858af52a42c03cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # LAB2 | Docker Image Distribution | |
| ## Build Image | |
| docker build -t [IMAGE-NAME]:[TAG] . | |
| ``` | |
| -f, --file: Name of Dockerfile | |
| --no-cache: Don't use cache | |
| -t: Name and Tag docker image `name:tag` format | |
| --label: Set metadata for an image | |
| ``` | |
| --- | |
| cd docker-image/weather-app | |
| cp Dockerfile Dockerfile.test | |
| docker build -t kudaliar032/weather-app:path-example1 -f Dockerfile.test . | |
| docker build -t kudaliar032/weather-app:path-example2 --label maintainer="adityarahman032@gmail.com" -f Dockerfile.test . | |
| --- | |
| docker build -t kudaliar032/weather-app:github https://github.com/linuxacademy/content-weather-app.git#remote-build | |
| --- | |
| mkdir tar-image | |
| cd tar-image | |
| git clone https://github.com/linuxacademy/content-weather-app.git | |
| cd content-weather-app | |
| git checkout remote-build | |
| tar -zcvf weather-app.tar.gz Dockerfile src | |
| docker build -t kudaliar032/weather-app:from-tar - < weather-app.tar.gz | |
| ## Multi-Stage Builds | |
| mkdir multi-stage-build | |
| cd multi-stage-build | |
| git clone https://github.com/linuxacademy/content-weather-app.git src | |
| vim Dockerfile | |
| ``` | |
| FROM node:lts AS build | |
| WORKDIR /app | |
| ADD src/ /app | |
| RUN npm install | |
| FROM node:alpine | |
| ENV NODE_ENV="production" | |
| COPY --from=build /app /app | |
| WORKDIR /app | |
| EXPOSE 3000 | |
| ENTRYPOINT ["./bin/www"] | |
| ``` | |
| docker image build -t kudaliar032/weather-app:multi-stage-build . | |
| docker images | |
| docker run -d --name multi-stage-build -p 8000:3000 kudaliar032/weather-app:multi-stage-build | |
| ## Docker Tagging | |
| docker build -t [IMAGE-NAME]:[TAG] | |
| docker tag [IMAGE-SRC]:[TAG] [IMAGE-TRGT]:[TAG] | |
| docker tag kudaliar032/weather-app:v5 kudaliar032/weather-app:latest | |
| ## Push to Docker Hub | |
| docker image push [USERNAME]/[IMAGE-NAME]:[TAG] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment