mirror of https://github.com/docker/docs.git
Merge pull request #13209 from docker/master
Publish updates from master
This commit is contained in:
commit
8a1f0097f7
|
|
@ -33,13 +33,23 @@ To get started with Dev Environments, you must have the following tools and exte
|
|||
|
||||
Click **Install** to download and install any missing tools.
|
||||
|
||||
### Add Git to your PATH on Windows
|
||||
|
||||
If you have already installed Git, and it's not detected properly, run the following command to check whether you can use Git with the CLI or PowerShell:
|
||||
|
||||
`$ git --version`
|
||||
|
||||
If it doesn't detect Git as a valid command, you must reinstall Git and ensure you choose the option **Git from the command line...** or the **Use Git and optional Unix tools...** on the **Adjusting your PATH environment** step.
|
||||
|
||||
{:width="300px"}
|
||||
|
||||
## Start a single container Dev Environment
|
||||
|
||||
The simplest way to get started with Dev Environments is to create a new environment by cloning the Git repository of the project you are working on. For example, let us create a new Dev Environment using a simple `single-dev-env` project from the [Docker Samples](https://github.com/dockersamples/single-dev-env){:target="_blank" rel="noopener" class="_"} GitHub repository.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> When cloning a Git repository using SSH, ensure you've added your SSH key to the ssh-agent. To do this, open a terminal and run `ssh-add <path to your public ssh key>`.
|
||||
> When cloning a Git repository using SSH, ensure you've added your SSH key to the ssh-agent. To do this, open a terminal and run `ssh-add <path to your private ssh key>`.
|
||||
|
||||
1. First, let's copy `git@github.com:dockersamples/single-dev-env.git` and add it to the **Create** field on the **Create a Development Environment** page.
|
||||
2. Now, click **Create**.
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
|
|
@ -170,13 +170,13 @@ context, refer to [exclude with .dockerignore](#exclude-with-dockerignore).
|
|||
>
|
||||
> docker build -t myimage:latest -<<EOF
|
||||
> FROM busybox
|
||||
> COPY somefile.txt .
|
||||
> COPY somefile.txt ./
|
||||
> RUN cat /somefile.txt
|
||||
> EOF
|
||||
>
|
||||
> # observe that the build fails
|
||||
> ...
|
||||
> Step 2/3 : COPY somefile.txt .
|
||||
> Step 2/3 : COPY somefile.txt ./
|
||||
> COPY failed: stat /var/lib/docker/tmp/docker-builder249218248/somefile.txt: no such file or directory
|
||||
> ```
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ touch somefile.txt
|
|||
# build an image using the current directory as context, and a Dockerfile passed through stdin
|
||||
docker build -t myimage:latest -f- . <<EOF
|
||||
FROM busybox
|
||||
COPY somefile.txt .
|
||||
COPY somefile.txt ./
|
||||
RUN cat /somefile.txt
|
||||
EOF
|
||||
```
|
||||
|
|
@ -232,7 +232,7 @@ the `hello.c` file from the ["hello-world" Git repository on GitHub](https://git
|
|||
```bash
|
||||
docker build -t myimage:latest -f- https://github.com/docker-library/hello-world.git <<EOF
|
||||
FROM busybox
|
||||
COPY hello.c .
|
||||
COPY hello.c ./
|
||||
EOF
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ builder pattern above:
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM golang:1.16
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
COPY app.go .
|
||||
COPY app.go ./
|
||||
RUN go get -d -v golang.org/x/net/html \
|
||||
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||
```
|
||||
|
|
@ -57,7 +57,7 @@ and forget to continue the line using the `\` character, for example.
|
|||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
COPY app .
|
||||
COPY app ./
|
||||
CMD ["./app"]
|
||||
```
|
||||
|
||||
|
|
@ -103,13 +103,13 @@ multi-stage builds.
|
|||
FROM golang:1.16
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
RUN go get -d -v golang.org/x/net/html
|
||||
COPY app.go .
|
||||
COPY app.go ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
|
||||
COPY --from=0 /go/src/github.com/alexellis/href-counter/app ./
|
||||
CMD ["./app"]
|
||||
```
|
||||
|
||||
|
|
@ -143,13 +143,13 @@ Dockerfile are re-ordered later, the `COPY` doesn't break.
|
|||
FROM golang:1.16 AS builder
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
RUN go get -d -v golang.org/x/net/html
|
||||
COPY app.go .
|
||||
COPY app.go ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
COPY --from=builder /go/src/github.com/alexellis/href-counter/app .
|
||||
COPY --from=builder /go/src/github.com/alexellis/href-counter/app ./
|
||||
CMD ["./app"]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -152,8 +152,8 @@ In its simplest form, the `COPY` command takes two parameters. The first paramet
|
|||
We’ll copy the `go.mod` and `go.sum` file into our working directory `/app` which, owing to our use of `WORKDIR`, is the current directory (`.`) inside the image.
|
||||
|
||||
```dockerfile
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
```
|
||||
|
||||
Now that we have the module files inside the Docker image that we are building, we can use the `RUN` command to execute the command `go mod download` there as well. This works exactly the same as if we were running `go` locally on our machine, but this time these Go modules will be installed into the a directory inside our image.
|
||||
|
|
@ -167,7 +167,7 @@ At this point, we have an image that is based on Go environment version 1.16 (or
|
|||
The next thing we need to do is to copy our source code into the image. We’ll use the `COPY` command just like we did with our module files before.
|
||||
|
||||
```dockerfile
|
||||
COPY *.go .
|
||||
COPY *.go ./
|
||||
```
|
||||
|
||||
This `COPY` command uses a wildcard to copy all files with `.go` extension located in the current directory on the host (the directory where the `Dockerfile` is located) into the current directory inside the image.
|
||||
|
|
@ -195,11 +195,11 @@ FROM golang:1.16-alpine
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY *.go .
|
||||
COPY *.go ./
|
||||
|
||||
RUN go build -o /docker-gs-ping
|
||||
|
||||
|
|
@ -218,8 +218,8 @@ FROM golang:1.16-alpine
|
|||
WORKDIR /app
|
||||
|
||||
# Download necessary Go modules
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# ... the rest of the Dockerfile is ...
|
||||
|
|
@ -351,11 +351,11 @@ FROM golang:1.16-buster AS build
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY *.go .
|
||||
COPY *.go ./
|
||||
|
||||
RUN go build -o /docker-gs-ping
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ $ curl http://localhost:8080/
|
|||
curl: (7) Failed to connect to localhost port 8080: Connection refused
|
||||
```
|
||||
|
||||
Our curl command failed because the connection to our server was refused. Meaning that we were not able to connect to localhost on port 8080. This is expected because our container is run in isolation which includes networking. Let’s stop the container and restart with port 8080 published on our local network.
|
||||
Our curl command failed because the connection to our server was refused. Meaning that we were not able to connect to localhost on port 8080. This is expected because our container is running in isolation which includes networking. Let’s stop the container and restart with port 8080 published on our local network.
|
||||
|
||||
To stop the container, press ctrl-c. This will return you to the terminal prompt.
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ $ curl --request GET \
|
|||
curl: (7) Failed to connect to localhost port 8080: Connection refused
|
||||
```
|
||||
|
||||
As you can see, our `curl` command failed because the connection to our server was refused. This means, we were not able to connect to the localhost on port 8080. This is expected because our container is run in isolation which includes networking. Let’s stop the container and restart with port 8080 published on our local network.
|
||||
As you can see, our `curl` command failed because the connection to our server was refused. It means that we were not able to connect to the localhost on port 8080. This is expected because our container is running in isolation which includes networking. Let’s stop the container and restart with port 8080 published on our local network.
|
||||
|
||||
To stop the container, press `ctrl-c`. This will return you to the terminal prompt.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ $ curl --request POST \
|
|||
curl: (7) Failed to connect to localhost port 8000: Connection refused
|
||||
```
|
||||
|
||||
Our curl command failed because the connection to our server was refused. Meaning that we were not able to connect to localhost on port 8000. This is expected because our container is run in isolation which includes networking. Let’s stop the container and restart with port 8000 published on our local network.
|
||||
Our curl command failed because the connection to our server was refused. It means that we were not able to connect to localhost on port 8000. This is expected because our container is running in isolation which includes networking. Let’s stop the container and restart with port 8000 published on our local network.
|
||||
|
||||
To stop the container, press ctrl-c. This will return you to the terminal prompt.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue