Docker Community Forums

Share and learn in the Docker community.

Docker run error - command not found

(Dheeru5544) #1

I am a newbie to docker. I am trying to dockerize a running application based on java. I have tar the entire file system and imported this archive as a docker image. Then, i have created a docker image from the tarball using the command “cat ubuntu_1.tar.gz | docker import - ubuntucopy:new”. When i am trying to run the image using " Docker run -it imagename:tag" it gives me an error saying no command specified. When i try to run using " Docker run -it imagename:tag /bin/bash it gives me an error saying no such file or folder. Please help me out with your suggestions. Thanks

(Sam) #2

sorry, not quite sure of the words… th tarfile is NOT the docker image… it is some files…
docker IMAGE is created from docker build command

the From in the dockerfile starts the filesystem…

I tar an existing app, and untar it when the container starts… but ONLY the folders that are the app (/opt/xxx)
(it is on a volume connected at run time, so the docker image doesn’t have to hold the 1.5 GB gzipped app image)

in the dockerfile, you have either


to identify the SINGLE application (executable) to run to keep the container alive.

my Dockerfile has
ENTRYPOINT ["/opt/"]

to launch the script which unbundles (zip or tar) the product file, and does some other setup before
launching the app… I also pass in from the docker run, some parameters to the container entrypoint command
to help the app decide which execution mode it is in.

(Dheeru5544) #3

I have an AMI with a running application in it. I have launched the AMI as an instance. It is based on RHEL 6.5. I have launched an other new ubuntu 14.04 instance and installed docker on it. I have stopped the application instance and detached the root volume and attached it to my new ubuntu 14.04 instance and mounted it to mount volume using the command [sudo mount /dev/xvda1 /mnt/] .
Then I have imported the docker image from the mounted root volume using the command [tar -c -C /mnt/ . | docker import - yourimagename:tag] . My image name is docimage:v1. Then I ran the container using command [ Docker run -it -p 443:443 docimage:v1 /bin/bash]. The container is in running state now. But for the application portal to run I have to go into the container and manually start services likw service httpd start, service postgresql start and service vpms start. Now the application portal is showing on the browser. To avoid the manual steps i have created a Dockerfile with the existing docimage:v1 image.
FROM docimage:v1
ENTRYPOINT service httpd start && service postgresql start && service vpms start && /bin/bash
I have built the new image from dockerfile ,docnewimage:v1. Now if i run the image the container is running and application is showing in the browser. I have pushed the image to dockerhub and pulled in from other linux machines such as ubuntu 16.04 and amazon linux. the container is running but failing in the vpms service to start. But when I am pulling the image to other ubuntu 14.04 the container is running perfect. Can someone help me out with this ?

(Sam) #4

thanks… very helpful info…

I think you are doing things the right way, altho this last comment on docker import examples might be an issue

Import from a local directory with new configurations
$ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
Note the sudo in this example – you must preserve the ownership of the files (especially root ownership) during the archiving with tar. If you are not root (or the sudo command) when you tar, then the ownerships might not get preserved.