docker / cli

The Docker CLI
Apache License 2.0
4.75k stars 1.88k forks source link

Running docker create does not create a new container #5087

Closed ydanylko closed 1 month ago

ydanylko commented 1 month ago

Description

Unfortunately I do not have an extensive way to reproduce this error as I am sure it will work fine for almost all of you. I have downloaded and created a docker image, it shows up in the list after running docker image ls. When running create as follows:

docker create -t -i -w /mnt/studentfiles/2024/2024MBI02/ nextgenusfs/funannotate --name annotate

I get the following output:

a6ab4e711e5c2c159957900d33b3754dcebef37c99d57680a804d06698dee931

Which I assume is the container tag. However, running docker container ls shows an empty list and trying to use the exec or start command also gives:

Error response from daemon: No such container: annotate

Why can I not see my container after creating it? Or maybe differently, why is my container not being created? I need to create a container for docker to be able to see my input and output directories so I am stuck here. If anybody knows a possible fix I would greatly appreciate it.

Reproduce

docker create -t -i -w /mnt/studentfiles/2024/2024MBI02/ nextgenusfs/funannotate --name annotate docker start or exec, or container ls

Expected behavior

Make a new container that shows up in the list

docker version

Client: Docker Engine - Community
 Version:           25.0.4
 API version:       1.44
 Go version:        go1.21.8
 Git commit:        1a576c5
 Built:             Wed Mar  6 16:32:12 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.4
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       061aa95
  Built:            Wed Mar  6 16:32:12 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    25.0.4
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.25.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 25
  Running: 0
  Paused: 0
  Stopped: 25
 Images: 7
 Server Version: 25.0.4
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-21-generic
 Operating System: Ubuntu 22.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 28
 Total Memory: 125.5GiB
 Name: midgard.bioinformatics-atgm.nl
 ID: 38b3d761-853f-47c8-8251-4e6fbbead06d
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

thaJeztah commented 1 month ago

docker create creates a container, but doesn't start it, so the container will have status created; docker ps / docker container ls by default only shows containers that are running.

docker create -t -i -w /mnt/studentfiles/2024/2024MBI02/ nextgenusfs/funannotate --name annotate
Unable to find image 'nextgenusfs/funannotate:latest' locally
latest: Pulling from nextgenusfs/funannotate
544676cb5e57: Pull complete
70e70a21d5b4: Pull complete
6e7811040d62: Pull complete
61a6b81c65dd: Pull complete
Digest: sha256:e634998bd023670bad59d4982862efb47389b1fe5d052432a7610dc98e5cf5bd
Status: Downloaded newer image for nextgenusfs/funannotate:latest
204bf12852d551855f4484989ce37ed0052c1abdc3b507e2e56dfdfeedd78efb
docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

To show containers that are not running, you can use the -a / --all option;

docker ps -a
CONTAINER ID   IMAGE                     COMMAND             CREATED          STATUS    PORTS     NAMES
204bf12852d5   nextgenusfs/funannotate   "--name annotate"   20 seconds ago   Created             stoic_archimedes

That said, I suspect you intended to pass --name annotate as option for docker (to give the container a name); the order of arguments is important, because anything passed after the image name is passed as command to be run in the container (or to be used as arguments for the container's entrypoint); in your case --name annotate is passed as command for the container, which can also be seen in the docker ps -a output above.

--name annotate is not a valid command in the container, so when starting the container, you'll see that it fails;

docker start 204bf12852d5
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "--name": executable file not found in $PATH: unknown
Error: failed to start containers: 204bf12852d5

If your intent was to name the container annotate, that option should go before the image name; also see the "usage" for the docker create command;

docker create --help

Usage:  docker create [OPTIONS] IMAGE [COMMAND] [ARG...]

Create a new container

Changing the --name to be before the image prevents that failure;

# remove the faulty container
docker rm stoic_archimedes

# crate a new container
docker create -t -i -w /mnt/studentfiles/2024/2024MBI02/ --name annotate nextgenusfs/funannotate

docker ps -a
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS    PORTS     NAMES
c00f371010d4   nextgenusfs/funannotate   "/bin/bash -c funann…"   12 seconds ago   Created             annotate

docker start annotate

However, the container does not have a process that expected to be running in the background, and it immediately exits after it's started;

docker ps -a
CONTAINER ID   IMAGE                     COMMAND                  CREATED              STATUS                     PORTS     NAMES
c00f371010d4   nextgenusfs/funannotate   "/bin/bash -c funann…"   About a minute ago   Exited (1) 3 seconds ago             annotate

And reading the container's logs show that it indeed expects it to be run interactively, not "detached" (in the background);

docker logs annotate

Usage:       funannotate <command> <arguments>
version:     1.8.17

Description: Funannotate is a genome prediction, annotation, and comparison pipeline.

Commands:
  clean       Find/remove small repetitive contigs
  sort        Sort by size and rename contig headers
  mask        Repeatmask genome assembly
...

Perhaps your intent was to run the container interactively, or to start it with a specific command? It looks like the container defaults to us funannotate as entrypoint, so in that case you may have to override the command to use a shell instead (e.g. bash);

# remove the old annotate container again
docker rm annotate

# run the container with "bash" as command. you can run "funannotate" inside the container;
docker run -t -i -w /mnt/studentfiles/2024/2024MBI02/ --name annotate nextgenusfs/funannotate bash
root@00dd43d4d500:/mnt/studentfiles/2024/2024MBI02# funannotate --version
funannotate v1.8.17
thaJeztah commented 1 month ago

I don't think there's a bug at hand here, so I'll close this ticket, but feel free to continue the conversation

ydanylko commented 1 month ago

Perhaps your intent was to run the container interactively, or to start it with a specific command? It looks like the container defaults to us funannotate as entrypoint, so in that case you may have to override the command to use a shell instead (e.g. bash);

# remove the old annotate container again
docker rm annotate

# run the container with "bash" as command. you can run "funannotate" inside the container;
docker run -t -i -w /mnt/studentfiles/2024/2024MBI02/ --name annotate nextgenusfs/funannotate bash
root@00dd43d4d500:/mnt/studentfiles/2024/2024MBI02# funannotate --version
funannotate v1.8.17

Hi, thank you so much for everything! I tried to run the image directly and this worked for some commands, however, for many commands docker cannot access my directories I need for input for the commands.. hence why I thought to make a container and mount the directories to it. Will that work or would you suggest another way or reason for the input issue for some directories?