@@ -83,25 +83,36 @@ func (gui *Gui) getContainersPanel() *panels.SideListPanel[*commands.Container]
8383 return sortContainers (a , b , gui .Config .UserConfig .Gui .LegacySortContainers )
8484 },
8585 Filter : func (container * commands.Container ) bool {
86- // Note that this is O(N*M) time complexity where N is the number of services
87- // and M is the number of containers. We expect N to be small but M may be large,
88- // so we will need to keep an eye on this.
89- if ! gui .Config .UserConfig .Gui .ShowAllContainers && ! isStandaloneContainer (container ) {
90- return false
91- }
92-
9386 if ! gui .State .ShowExitedContainers && container .Container .State == "exited" {
9487 return false
9588 }
9689
97- // Filter by selected project. Containers with no project (truly
98- // standalone, not from any compose project) are always shown.
99- selectedProject := gui .getSelectedProjectName ()
100- if selectedProject == "" {
101- selectedProject = gui .DockerCommand .LocalProjectName
102- }
103- if selectedProject != "" && container .ProjectName != "" && container .ProjectName != selectedProject {
104- return false
90+ // Only apply project and standalone filtering when we are inside a
91+ // docker-compose project. Outside of a compose project all
92+ // containers are shown in a flat list regardless of which compose
93+ // project they belong to.
94+ if gui .DockerCommand .InDockerComposeProject {
95+ // This check must be inside the InDockerComposeProject guard:
96+ // outside a compose project, services are still derived from
97+ // container labels, so compose-managed containers from other
98+ // projects would be incorrectly hidden.
99+ //
100+ // Note that this is O(N*M) time complexity where N is the number of services
101+ // and M is the number of containers. We expect N to be small but M may be large,
102+ // so we will need to keep an eye on this.
103+ if ! gui .Config .UserConfig .Gui .ShowAllContainers && ! isStandaloneContainer (container ) {
104+ return false
105+ }
106+
107+ // Filter by selected project. Containers with no project (truly
108+ // standalone, not from any compose project) are always shown.
109+ selectedProject := gui .getSelectedProjectName ()
110+ if selectedProject == "" {
111+ selectedProject = gui .DockerCommand .LocalProjectName
112+ }
113+ if selectedProject != "" && container .ProjectName != "" && container .ProjectName != selectedProject {
114+ return false
115+ }
105116 }
106117
107118 return true
0 commit comments