wslc: add Config (env, cmd, entrypoint, user, workdir) to container inspect output (#40403)
beena352 committed
May 5, 2026 at 14:00 UTC
8dfa8a7f2f28125206c4c6f3efcf65f88cd3003e
4 files changed
+56
-2
src/windows/inc/docker_schema.h
+6
-1
@@ -260,8 +260,13 @@ struct ContainerInspectState
260
struct ContainerConfig
261
{
262
std::string Image;
263
+ std::string User;
264
+ std::string WorkingDir;
265
+ std::optional<std::vector<std::string>> Env;
266
+ std::optional<std::vector<std::string>> Cmd;
267
+ std::optional<std::vector<std::string>> Entrypoint;
268
264
- NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(ContainerConfig, Image);
269
+ NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(ContainerConfig, Image, User, WorkingDir, Env, Cmd, Entrypoint);
270
};
271
272
struct InspectMount
src/windows/inc/wslc_schema.h
+13
-1
@@ -56,6 +56,17 @@ struct InspectHostConfig
56
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(InspectHostConfig, NetworkMode);
57
};
58
59
+struct InspectContainerConfig
60
+{
61
+ std::optional<std::vector<std::string>> Env;
62
+ std::optional<std::vector<std::string>> Cmd;
63
+ std::optional<std::vector<std::string>> Entrypoint;
64
+ std::string User;
65
+ std::string WorkingDir;
66
+
67
+ NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(InspectContainerConfig, Env, Cmd, Entrypoint, User, WorkingDir);
68
+};
69
+
70
struct InspectContainer
71
{
72
std::string Id;
@@ -64,11 +75,12 @@ struct InspectContainer
75
std::string Image;
76
InspectState State;
77
InspectHostConfig HostConfig;
78
+ InspectContainerConfig Config;
79
std::map<std::string, std::vector<InspectPortBinding>> Ports;
80
std::vector<InspectMount> Mounts;
81
std::map<std::string, std::string> Labels;
82
71
- NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(InspectContainer, Id, Name, Created, Image, State, HostConfig, Ports, Mounts, Labels);
83
+ NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(InspectContainer, Id, Name, Created, Image, State, HostConfig, Config, Ports, Mounts, Labels);
84
};
85
86
struct ImageConfig
src/windows/wslcsession/WSLCContainer.cpp
+6
@@ -1139,6 +1139,12 @@ WslcInspectContainer WSLCContainerImpl::BuildInspectContainer(const DockerInspec
1139
1140
wslcInspect.HostConfig.NetworkMode = dockerInspect.HostConfig.NetworkMode;
1141
1142
+ wslcInspect.Config.Env = dockerInspect.Config.Env;
1143
+ wslcInspect.Config.Cmd = dockerInspect.Config.Cmd;
1144
+ wslcInspect.Config.Entrypoint = dockerInspect.Config.Entrypoint;
1145
+ wslcInspect.Config.User = dockerInspect.Config.User;
1146
+ wslcInspect.Config.WorkingDir = dockerInspect.Config.WorkingDir;
1147
+
1148
// Map WSLC port mappings (Windows host ports only). HostIp is not set here and will use
1149
// the default value ("127.0.0.1") defined in the InspectPortBinding schema.
1150
for (const auto& e : m_mappedPorts)
test/windows/WSLCTests.cpp
+31
@@ -5766,6 +5766,37 @@ class WSLCTests
5766
5767
VERIFY_SUCCEEDED(container.Get().Delete(WSLCDeleteFlagsNone));
5768
}
5769
+
5770
+ // Test that Config fields are populated in inspect output.
5771
+ {
5772
+ const std::string envVar = "WSLC_TEST_VAR=hello";
5773
+ const std::string workDir = "/tmp";
5774
+
5775
+ WSLCContainerLauncher launcher("debian:latest", "test-container-inspect-config", {"99999"}, {envVar});
5776
+ launcher.SetEntrypoint({"sleep"});
5777
+ launcher.SetWorkingDirectory(std::string{workDir});
5778
+ launcher.SetUser("nobody");
5779
+
5780
+ auto container = launcher.Launch(*m_defaultSession);
5781
+ auto details = container.Inspect();
5782
+
5783
+ const auto& config = details.Config;
5784
+
5785
+ VERIFY_IS_TRUE(config.Env.has_value());
5786
+ VERIFY_IS_TRUE(std::ranges::find(*config.Env, envVar) != config.Env->end());
5787
+
5788
+ VERIFY_ARE_EQUAL(config.WorkingDir, workDir);
5789
+
5790
+ VERIFY_IS_TRUE(config.Cmd.has_value());
5791
+ VERIFY_ARE_EQUAL(1u, config.Cmd->size());
5792
+ VERIFY_ARE_EQUAL(config.Cmd->at(0), std::string{"99999"});
5793
+
5794
+ VERIFY_IS_TRUE(config.Entrypoint.has_value());
5795
+ VERIFY_ARE_EQUAL(1u, config.Entrypoint->size());
5796
+ VERIFY_ARE_EQUAL(config.Entrypoint->at(0), std::string{"sleep"});
5797
+
5798
+ VERIFY_ARE_EQUAL(config.User, std::string{"nobody"});
5799
+ }
5800
}
5801
5802
WSLC_TEST_METHOD(Exec)