Skip to content

Commit 69654ca

Browse files
committed
readme update with more container runtime connection info and extra logging for the docker client setup
Signed-off-by: Kyle Quest <kcq.public@gmail.com>
1 parent 8e9d56d commit 69654ca

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Elixir application images:
158158
- [`REGISTRY` COMMAND OPTIONS](#registry-command-options)
159159
- [`VULNERABILITY` COMMAND OPTIONS](#vulnerability-command-options)
160160
- [RUNNING CONTAINERIZED](#running-containerized)
161-
- [DOCKER CONNECT OPTIONS](#docker-connect-options)
161+
- [CONTAINER RUNTIME CONNECT OPTIONS](#container-runtime-connect-options)
162162
- [HTTP PROBE COMMANDS](#http-probe-commands)
163163
- [DEBUGGING MINIFIED CONTAINERS](#debugging-minified-containers)
164164
- [MINIFYING COMMAND LINE TOOLS](#minifying-command-line-tools)
@@ -1000,7 +1000,9 @@ The workflow above indicates four steps:
10001000
- A docker tag command for naming/tagging the slimmed image with your DockerHub account remote repository name which could be the same name(IMAGE_NAME) as the slimmed image; A docker push command to push the slimmed image to your Dockerhub account remote repository.
10011001

10021002

1003-
## DOCKER CONNECT OPTIONS
1003+
## CONTAINER RUNTIME CONNECT OPTIONS
1004+
1005+
By default, **Mint** will try to connect to the Docker container runtime. Some commands (e.g., `debug`) support selecting a runtime type using the `--runtime` flag, which affects what **Mint** will look for when it's trying to connect to the target container runtime.
10041006

10051007
If you don't specify any Docker connect options the **Mint** app expects to find the Docker Unix socket (`/var/run/docker.sock`) or the following environment variables: `DOCKER_HOST`, `DOCKER_TLS_VERIFY` (optional), `DOCKER_CERT_PATH` (required if `DOCKER_TLS_VERIFY` is set to `"1"`). Note that the `DOCKER_HOST` environment variable can be used to point to a Unix socket address (in case the default Unix socket isn't there). This is useful when you use Docker Desktop and you haven't configured Docker Desktop to create the default Unix socket.
10061008

@@ -1010,7 +1012,9 @@ If the Docker environment variables are configured to use TLS and to verify the
10101012

10111013
You can override all Docker connection options using these flags: `--host`, `--tls`, `--tls-verify`, `--tls-cert-path`, `--crt-context`. These flags correspond to the standard Docker options (and the environment variables). Note that you can also use the `--host` flag (similar to `DOCKER_HOST`) to point to a Unix socket (e.g., `--host=unix:///var/run/docker.sock`).
10121014

1013-
The `--crt-context` flag is currently supported with the Docker runtime and it's similar to using the `--context` flag or `DOCKER_CONTEXT`. Note that Mint will use `DOCKER_CONTEXT` if it's configured.
1015+
The `--crt-connection` flag is similar to the `--host` flag, but it's used to point to non-Docker container runtimes like Podman (`mint --crt-connection tcp://localhost:8899 debug --runtime podman --target YOUR_CONTAINER_NAME_OR_ID`). Eventually both flags will merge and there'll be only `--crt-connection`. For now `--host` is still there for backward compatibility reasons.
1016+
1017+
The `--crt-context` flag is currently supported with the Docker runtime and it's similar to using the `--context` flag or `DOCKER_CONTEXT` with the standard Docker CLI. Note that Mint will use `DOCKER_CONTEXT` if it's configured.
10141018

10151019
If you want to use TLS with verification:
10161020

@@ -1030,6 +1034,27 @@ You can either use `--host` or `DOCKER_HOST` to point to the Docker Desktop's Un
10301034

10311035
To configure Docker Desktop to create the default Unix socket open its UI and go to `Settings -> Advanced` where you need to check the `Enable default Docker socket (Requires password)` option.
10321036

1037+
### COLIMA
1038+
1039+
Similar to Docker Desktop, but the socked will need to be configured to use `unix://${HOME}/.colima/<PROFILE>/docker.sock` where `${HOME}/.colima` is `$COLIMA_HOME` and `<PROFILE>` is `default` (unless you created a custom profile).
1040+
1041+
The Colima Docker socket can also be accessed through Docker context.
1042+
1043+
### LIMA
1044+
1045+
Similar to Colima: `unix://${HOME}/.lima/<INSTANCE>/docker.sock` where `<INSTANCE>` is usually `default`.
1046+
1047+
When you start a Lima instance the CLI will also print the instructions to configure Docker context with the Docker socket Lima creates. If you configure the context and make it active then **Mint** will pick it up as a regular Docker socket.
1048+
1049+
### PODMAN
1050+
1051+
Depending on how the Podman container runtime is installed and if you are using Podman Desktop you may need to start Podman services to expose the API **Mint** is using to interact with the Podman container runtime. Right now it's your responsibility, but the future versions will auto-start the Podman service.
1052+
1053+
Here's what you'll need to do:
1054+
1055+
1. Start the service (it can be done with a unix socket too): `podman system service --time=0 tcp://localhost:8899`
1056+
2. Provide the same connection string to the **Mint** command (`debug` in this example) using the global `--crt-connection` flag: `mint --crt-connection tcp://localhost:8899 debug --runtime podman --target YOUR_CONTAINER_NAME_OR_ID`
1057+
10331058
## HTTP PROBE COMMANDS
10341059

10351060
If the HTTP probe is enabled (note: it is enabled by default) it will default to running `GET /` with HTTP and then HTTPS on every exposed port. You can add additional commands using the `--http-probe-cmd`, `--http-probe-cmd-upload` and `--http-probe-cmd-file` options.

pkg/app/master/inspectors/container/container_inspector.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ func (i *Inspector) FinishMonitoring() {
13651365
}
13661366

13671367
func (i *Inspector) initContainerChannels() error {
1368-
const op = "container.Inspector.initContainerChannels"
1368+
logger := i.logger.WithField("op", "container.Inspector.initContainerChannels")
13691369

13701370
var cn string
13711371
if i.Overrides != nil {
@@ -1402,21 +1402,26 @@ func (i *Inspector) initContainerChannels() error {
14021402
switch i.SensorIPCMode {
14031403
case SensorIPCModeDirect, SensorIPCModeProxy:
14041404
ipcMode = i.SensorIPCMode
1405+
logger.WithField("ipc.mode", ipcMode).Trace("configured ipc.mode")
14051406
default:
14061407
if i.InContainer || i.isHostNetworked() {
14071408
ipcMode = SensorIPCModeDirect
1409+
logger.WithField("ipc.mode", ipcMode).Trace("container ipc.mode")
14081410
} else {
14091411
ipcMode = SensorIPCModeProxy
1412+
logger.WithField("ipc.mode", ipcMode).Trace("default/proxy ipc.mode")
14101413
}
14111414
}
14121415

14131416
var cmdPort, evtPort string
14141417
switch ipcMode {
14151418
case SensorIPCModeDirect:
1419+
logger.Trace("direct ipc.mode target config")
14161420
i.TargetHost = ipAddr
14171421
cmdPort = i.CmdPort.Port()
14181422
evtPort = i.EvtPort.Port()
14191423
case SensorIPCModeProxy:
1424+
logger.Trace("proxy ipc.mode target config")
14201425
i.DockerHostIP = dockerhost.GetIP(i.APIClient)
14211426
i.TargetHost = i.DockerHostIP
14221427
cmdPortBindings := i.ContainerInfo.NetworkSettings.Ports[i.CmdPort]
@@ -1430,8 +1435,7 @@ func (i *Inspector) initContainerChannels() error {
14301435
i.TargetHost = i.SensorIPCEndpoint
14311436
}
14321437

1433-
i.logger.WithFields(log.Fields{
1434-
"op": op,
1438+
logger.WithFields(log.Fields{
14351439
"in.container": i.InContainer,
14361440
"container.network": cn,
14371441
"ipc.mode": ipcMode,

pkg/docker/dockerhost/host.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
dockerapi "github.com/fsouza/go-dockerclient"
99
log "github.com/sirupsen/logrus"
10+
11+
"github.com/mintoolkit/mint/pkg/util/jsonutil"
1012
)
1113

1214
const (
@@ -15,16 +17,17 @@ const (
1517

1618
// GetIP returns the Docker host IP address
1719
func GetIP(apiClient *dockerapi.Client) string {
20+
logger := log.WithField("op", "dockerhost.GetIP")
1821
dockerHost := os.Getenv("DOCKER_HOST")
22+
logger.WithField("DOCKER_HOST", dockerHost).Trace("os.Getenv")
1923
if dockerHost == "" {
2024
if apiClient != nil {
2125
netInfo, err := apiClient.NetworkInfo("bridge")
2226
if err != nil {
23-
log.WithFields(log.Fields{
24-
"op": "dockerhost.GetIP",
25-
"error": err,
26-
}).Debug("apiClient.NetworkInfo")
27+
logger.WithError(err).Debug("apiClient.NetworkInfo")
2728
} else {
29+
logger.WithField("data", jsonutil.ToString(netInfo)).Trace("netInfo")
30+
2831
if netInfo != nil && netInfo.Name == "bridge" {
2932
if len(netInfo.IPAM.Config) > 0 {
3033
return netInfo.IPAM.Config[0].Gateway

0 commit comments

Comments
 (0)