This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 177
updating dockerfile and readme with info on COPY and wildcards in Docker #1
Open
JamesEarle
wants to merge
2
commits into
Azure-Samples:master
Choose a base branch
from
JamesEarle:dockerfile-change
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| FROM node:8.2.0-alpine | ||
| RUN mkdir -p /usr/src/app | ||
| COPY ./app/* /usr/src/app/ | ||
| COPY ./app/ /usr/src/app/ | ||
| WORKDIR /usr/src/app | ||
| RUN npm install | ||
| CMD node /usr/src/app/index.js |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,36 @@ This sample is a very simple NodeJS application used to demonstrate [Azure Conta | |
|
|
||
| The packaged version of the application is [available on Docker Hub](https://hub.docker.com/r/microsoft/aci-helloworld/). | ||
|
|
||
| # Note | ||
|
|
||
| Most, if not all, Dockerfiles contain commands that copy your source code to the container. It is helpful to note that when copying files from your application into the container, you can use wildcard characters such as `*` and `?`. The `*` character will add all files to the destination directory that match it's pattern. The `?` character will do the same but can only be replaced by a single character. | ||
|
|
||
| ```Dockerfile | ||
| COPY *.jpg /myDir/ # adds all jpg files to /myDir/ | ||
| COPY pic-?.jpg /myDir/ # adds all files that match the pattern, e.g. pic-1.jpg, pic-2.jpg | ||
| ``` | ||
|
|
||
| When copying entire directories, avoid using the wildcard `*` after the source directory path (e.g. `./dir/*`). This will copy all files in all subdirectories, but **will not maintain the original directory structure when moved to the destination folder**. Instead you can just leave it out as `COPY ./dir/ /myDir/`. This will maintain the directory structure of your application inside the container. | ||
|
|
||
| # Debugging Docker Containers | ||
| Application not running? Take a look inside your container to see why. First list containers. Using the `-l` argument with `docker ps` will show all containers whether or not they are running. This is particularly useful if your application is crashing. | ||
|
|
||
| ```bash | ||
| docker ps -l | ||
|
|
||
| CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
| d73e9071a2d0 aci-hello-world "npm start" 10 seconds ago Up 10 seconds 8080/tcp, 0.0.0.0:8080->80/tcp keen_jepsen | ||
| ``` | ||
|
|
||
| If your container has a statys of `Exited(1)` you know something has gone wrong. Take a look at your application logs using the `docker logs` command to debug. If there are any application errors, they will be shown here. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this image is intended as an ACI learning vehicle, perhaps mention also how to view logs via the Azure CLI: az container logs Also, typo: statys (status) |
||
|
|
||
| ```bash | ||
| docker logs d73e9071a2d0 | ||
|
|
||
| app@0.0.0 start /usr/src/app | ||
| node index.js | ||
| ``` | ||
|
|
||
|
|
||
| # Contributing | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...match its pattern." (no
')