Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Docker say it can't execute 'bash"?

Tags:

docker

I'm using Docker on MacOSX (with Boot2Docker).

I can run images from Docker Hub.

However, when I try to run one of my own images like this:

docker run -P mylocalimage 

or

docker run -P mylocalimage bin/a3-write-back 

or

... 

I get:

docker "env: can't execute 'bash': No such file or directory" 

I guess that it can't find a bash binary to execute in the container, but why?

The base image is errordeveloper/oracle-jdk

Thanks for any help.

Ashley.

[{     "Architecture": "amd64",     "Author": "ABC [email protected]",     "Checksum": "tarsum.dev+sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",     "Comment": "",     "Config": {         "AttachStderr": false,         "AttachStdin": false,         "AttachStdout": false,         "Cmd": [],         "CpuShares": 0,         "Cpuset": "",         "Domainname": "",         "Entrypoint": [             "bin/a3-write-back"         ],         "Env": [             "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",             "JAVA_HOME=/usr/jdk1.8.0_25"         ],         "ExposedPorts": null,         "Hostname": "5bf0de3d0926",         "Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",         "MacAddress": "",         "Memory": 0,         "MemorySwap": 0,         "NetworkDisabled": false,         "OnBuild": [],         "OpenStdin": false,         "PortSpecs": null,         "StdinOnce": false,         "Tty": false,         "User": "daemon",         "Volumes": null,         "WorkingDir": "/opt/docker"     },     "Container": "987d2279b6e42195fe8e732c0637798926db6cfaeab93fcc25a3f10dac73f111",     "ContainerConfig": {         "AttachStderr": false,         "AttachStdin": false,         "AttachStdout": false,         "Cmd": [             "/bin/sh",             "-c",             "#(nop) CMD []"         ],         "CpuShares": 0,         "Cpuset": "",         "Domainname": "",         "Entrypoint": [             "bin/a3-write-back"         ],         "Env": [             "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",             "JAVA_HOME=/usr/jdk1.8.0_25"         ],         "ExposedPorts": null,         "Hostname": "5bf0de3d0926",         "Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",         "MacAddress": "",         "Memory": 0,         "MemorySwap": 0,         "NetworkDisabled": false,         "OnBuild": [],         "OpenStdin": false,         "PortSpecs": null,         "StdinOnce": false,         "Tty": false,         "User": "daemon",         "Volumes": null,         "WorkingDir": "/opt/docker"     },     "Created": "2015-01-13T05:25:38.467586784Z",     "DockerVersion": "1.4.1",     "Id": "ddbd5d3f52cc5fd41605c95e4525cd2f3e0808a3741b3f8d77f46f0661945f7b",     "Os": "linux",     "Parent": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",     "Size": 0,     "VirtualSize": 390826666 } ] 
like image 550
Ashley Aitken Avatar asked Jan 15 '15 08:01

Ashley Aitken


People also ask

Does Docker have bash?

Once you have your Docker container up and running, you can work with the environment of the Docker container in the same way you would do with an Ubuntu machine. You can access the bash or shell of the container and execute commands inside it and play around with the file system.

Does Alpine have bash?

By default, bash is not included with BusyBox and Alpine Linux. The postmarketOS project, which is designed to run on mobile devices, is based on Alpine Linux. Many Docker images are also based upon Alpine, and you may install bash shell in Docker-based images too.

What shell does Docker use?

Docker Dockerfiles SHELL InstructionThe default shell on Linux is ["/bin/sh", "-c"] , and on Windows is ["cmd", "/S", "/C"] . The SHELL instruction must be written in JSON form in a Dockerfile.


2 Answers

Your image is based on busybox, which doesn't have a bash shell. It does have a shell at /bin/sh.

So this doesn't work:

$ docker run -it busybox bash exec: "bash": executable file not found in $PATH2015/01/15 11:09:08 Error response from daemon:  Cannot start container a5074af2f81f8cc1eb0076f4ec9ada5f87be1440006f54a9b06ab701fc60176a: exec:   "bash": executable file not found in $PATH 

But this does:

$ docker run -it busybox /bin/sh / # 

There may be further complications due to your entrypoint script, but you can always override that.

like image 103
Adrian Mouat Avatar answered Sep 23 '22 00:09

Adrian Mouat


This won't work if your image has a defined ENTRYPOINT. For these cases use: ' docker run -it --entrypoint /bin/bash '

like image 31
10raw Avatar answered Sep 21 '22 00:09

10raw