mirror of https://github.com/docker/cli.git
Compare commits
8 Commits
b958678089
...
e797a96581
Author | SHA1 | Date |
---|---|---|
David Karlsson | e797a96581 | |
Sebastiaan van Stijn | a5fb752ecf | |
Laura Brehm | 4e64c59d64 | |
Jonathan A. Sternberg | 3472bbc28a | |
Laura Brehm | 649e564ee0 | |
Sebastiaan van Stijn | e1213edcc6 | |
Jonathan A. Sternberg | b1956f5073 | |
David Karlsson | a80c7c4117 |
|
@ -67,7 +67,7 @@ jobs:
|
|||
name: Update Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: 1.22.7
|
||||
-
|
||||
name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
|
|
|
@ -180,7 +180,7 @@ func toWslPath(s string) string {
|
|||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("mnt/%s%s", drive, p)
|
||||
return fmt.Sprintf("mnt/%s%s", strings.ToLower(drive), p)
|
||||
}
|
||||
|
||||
func parseUNCPath(s string) (drive, p string, ok bool) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
@ -9,21 +10,48 @@ import (
|
|||
)
|
||||
|
||||
func TestWslSocketPath(t *testing.T) {
|
||||
u, err := url.Parse("unix:////./c:/my/file/path")
|
||||
assert.NilError(t, err)
|
||||
|
||||
// Ensure host is empty.
|
||||
assert.Equal(t, u.Host, "")
|
||||
|
||||
// Use a filesystem where the WSL path exists.
|
||||
fs := fstest.MapFS{
|
||||
"mnt/c/my/file/path": {},
|
||||
testCases := []struct {
|
||||
doc string
|
||||
fs fs.FS
|
||||
url string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
doc: "filesystem where WSL path does not exist",
|
||||
fs: fstest.MapFS{
|
||||
"my/file/path": {},
|
||||
},
|
||||
url: "unix:////./c:/my/file/path",
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
doc: "filesystem where WSL path exists",
|
||||
fs: fstest.MapFS{
|
||||
"mnt/c/my/file/path": {},
|
||||
},
|
||||
url: "unix:////./c:/my/file/path",
|
||||
expected: "/mnt/c/my/file/path",
|
||||
},
|
||||
{
|
||||
doc: "filesystem where WSL path exists uppercase URL",
|
||||
fs: fstest.MapFS{
|
||||
"mnt/c/my/file/path": {},
|
||||
},
|
||||
url: "unix:////./C:/my/file/path",
|
||||
expected: "/mnt/c/my/file/path",
|
||||
},
|
||||
}
|
||||
assert.Equal(t, wslSocketPath(u.Path, fs), "/mnt/c/my/file/path")
|
||||
|
||||
// Use a filesystem where the WSL path doesn't exist.
|
||||
fs = fstest.MapFS{
|
||||
"my/file/path": {},
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.doc, func(t *testing.T) {
|
||||
u, err := url.Parse(tc.url)
|
||||
assert.NilError(t, err)
|
||||
// Ensure host is empty.
|
||||
assert.Equal(t, u.Host, "")
|
||||
|
||||
result := wslSocketPath(u.Path, tc.fs)
|
||||
|
||||
assert.Equal(t, result, tc.expected)
|
||||
})
|
||||
}
|
||||
assert.Equal(t, wslSocketPath(u.Path, fs), "")
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/cli/cli/version"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
@ -94,7 +95,9 @@ func startCobraCommandTimer(mp metric.MeterProvider, attrs []attribute.KeyValue)
|
|||
metric.WithAttributes(cmdStatusAttrs...),
|
||||
)
|
||||
if mp, ok := mp.(MeterProvider); ok {
|
||||
mp.ForceFlush(ctx)
|
||||
if err := mp.ForceFlush(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -358,7 +358,9 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
|
|||
|
||||
mp := dockerCli.MeterProvider()
|
||||
if mp, ok := mp.(command.MeterProvider); ok {
|
||||
defer mp.Shutdown(ctx)
|
||||
if err := mp.Shutdown(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed")
|
||||
}
|
||||
|
|
|
@ -725,7 +725,7 @@ to the `my-net` network.
|
|||
|
||||
```console
|
||||
$ docker network create my-net
|
||||
$ docker run -itd --network=my-net busybox
|
||||
$ docker run --network=my-net nginx
|
||||
```
|
||||
|
||||
You can also choose the IP addresses for the container with `--ip` and `--ip6`
|
||||
|
@ -734,7 +734,7 @@ static IP to containers, you must specify subnet block for the network.
|
|||
|
||||
```console
|
||||
$ docker network create --subnet 192.0.2.0/24 my-net
|
||||
$ docker run -itd --network=my-net --ip=192.0.2.69 busybox
|
||||
$ docker run --network=my-net --ip=192.0.2.69 nginx
|
||||
```
|
||||
|
||||
To connect the container to more than one network, repeat the `--network` option.
|
||||
|
@ -742,7 +742,7 @@ To connect the container to more than one network, repeat the `--network` option
|
|||
```console
|
||||
$ docker network create --subnet 192.0.2.0/24 my-net1
|
||||
$ docker network create --subnet 192.0.3.0/24 my-net2
|
||||
$ docker run -itd --network=my-net1 --network=my-net2 busybox
|
||||
$ docker run --network=my-net1 --network=my-net2 nginx
|
||||
```
|
||||
|
||||
To specify options when connecting to more than one network, use the extended syntax
|
||||
|
@ -762,7 +762,7 @@ for the `--network` flag. Comma-separated options that can be specified in the e
|
|||
```console
|
||||
$ docker network create --subnet 192.0.2.0/24 my-net1
|
||||
$ docker network create --subnet 192.0.3.0/24 my-net2
|
||||
$ docker run -itd --network=name=my-net1,ip=192.0.2.42 --network=name=my-net2,ip=192.0.3.42 busybox
|
||||
$ docker run --network=name=my-net1,ip=192.0.2.42 --network=name=my-net2,ip=192.0.3.42 nginx
|
||||
```
|
||||
|
||||
`sysctl` settings that start with `net.ipv4.`, `net.ipv6.` or `net.mpls.` can be
|
||||
|
@ -777,7 +777,7 @@ assigns the IPv4 address `192.0.2.42`.
|
|||
|
||||
```console
|
||||
$ docker network create --subnet 192.0.2.0/24 my-net
|
||||
$ docker run -itd --network=name=my-net,\"driver-opt=com.docker.network.endpoint.sysctls=net.ipv4.conf.IFNAME.log_martians=1,net.ipv4.conf.IFNAME.forwarding=0\",ip=192.0.2.42 busybox
|
||||
$ docker run --network=name=my-net,\"driver-opt=com.docker.network.endpoint.sysctls=net.ipv4.conf.IFNAME.log_martians=1,net.ipv4.conf.IFNAME.forwarding=0\",ip=192.0.2.42 nginx
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
|
|
|
@ -37,7 +37,7 @@ You can also use the `docker run --network=<network-name>` option to start a
|
|||
container and immediately connect it to a network.
|
||||
|
||||
```console
|
||||
$ docker run -itd --network=multi-host-network busybox
|
||||
$ docker run --network=multi-host-network nginx
|
||||
```
|
||||
|
||||
### <a name="ip"></a> Specify the IP address a container will use on a given network (--ip)
|
||||
|
|
|
@ -84,10 +84,10 @@ for more information about different endpoint modes.
|
|||
### Connect containers
|
||||
|
||||
When you start a container, use the `--network` flag to connect it to a network.
|
||||
This example adds the `busybox` container to the `mynet` network:
|
||||
This example adds the `nginx` container to the `mynet` network:
|
||||
|
||||
```console
|
||||
$ docker run -itd --network=mynet busybox
|
||||
$ docker run --network=mynet nginx
|
||||
```
|
||||
|
||||
If you want to add a container to a network after the container is already
|
||||
|
|
|
@ -25,10 +25,10 @@ all results in a JSON object.
|
|||
Connect two containers to the default `bridge` network:
|
||||
|
||||
```console
|
||||
$ sudo docker run -itd --name=container1 busybox
|
||||
$ sudo docker run -d --name=container1 nginx
|
||||
f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27
|
||||
|
||||
$ sudo docker run -itd --name=container2 busybox
|
||||
$ sudo docker run -d --name=container2 nginx
|
||||
bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727
|
||||
```
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ $ docker network connect multi-host-network container1
|
|||
You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network.
|
||||
|
||||
```console
|
||||
$ docker run -itd --network=multi-host-network --ip 172.20.88.22 --ip6 2001:db8::8822 busybox
|
||||
$ docker run --network=multi-host-network --ip 172.20.88.22 --ip6 2001:db8::8822 nginx
|
||||
```
|
||||
|
||||
You can pause, restart, and stop containers that are connected to a network.
|
||||
|
|
|
@ -51,10 +51,10 @@ for more information about different endpoint modes.
|
|||
## Connect containers
|
||||
|
||||
When you start a container, use the `--network` flag to connect it to a network.
|
||||
This example adds the `busybox` container to the `mynet` network:
|
||||
This example adds the `nginx` container to the `mynet` network:
|
||||
|
||||
```console
|
||||
$ docker run -itd --network=mynet busybox
|
||||
$ docker run -d --network=mynet nginx
|
||||
```
|
||||
|
||||
If you want to add a container to a network after the container is already
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to the default `bridge` network:
|
||||
|
||||
```console
|
||||
$ sudo docker run -itd --name=container1 busybox
|
||||
$ sudo docker run -d --name=container1 nginx
|
||||
f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27
|
||||
|
||||
$ sudo docker run -itd --name=container2 busybox
|
||||
$ sudo docker run -d --name=container2 nginx
|
||||
bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue