docker / docker/cli

container ls --filter name , regex start anchor has an awkward behavior

Open
#1,201 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/ux
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description


BUG REPORT INFORMATION

Description

The --filter option for container ls seem to support regex. For example you can use classes ([abc]), quantifiers (*,+,{x}), end anchor ($). But for some reason using start anchor (^) does not lead to expected results.

Steps to reproduce the issue:

  1. From any image, create or run 3 named (--name) containers: a1, a2, ba2.
  2. Run docker container ls -aqf name=^a

Describe the results you received:
Empty list of containers ids

Describe the results you expected:
A list of container ids, whose name starts with an a character.

Additional information you deem important (e.g. issue happens only occasionally):

It does not matter, whether the container runs or not. Not only because I used the -a flag, but also because I have tested both with containers running and not. The issue is equal in both cases.

I did not find any info on the official docs for container ls regarding the --filter option, but I did test different regex patterns and they worked. For example, having the above containers a1, a2, ba2, I could fetch ba2 using -aqf name=[ab]{2}.

I executed the exact same test with named networks a1, a2, ba2. Contrary to container ls the result matched the expectation.

Output of docker version:

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:20 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:15:30 2018
  OS/Arch:      linux/amd64
  Experimental: false

Output of docker info:

Containers: 6
 Running: 6
 Paused: 0
 Stopped: 0
Images: 47
Server Version: 18.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-24-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.68GiB
Name: xxx
ID: ICQC:MWTE:VWKT:5Z2W:VCKA:W2O5:2BSZ:6GEZ:K5B2:Y7XK:MMMJ:HYDS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

Physical machine

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the docker container ls --filter name handling and compare it with the named-network filter behavior described in the report. Add a regression case using containers named a1, a2, and ba2 with the ^a filter, then verify that only names beginning with a are returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.