Docker Community Forums

Share and learn in the Docker community.

Unable to run container

Dear All,
I am new to docker. I have downloaded the centos image and Start the container with the latest image and install httpd

[root@dlp ~]# docker run centos /bin/bash -c “yum -y update; yum -y install httpd”

after that registered the image
[root@dlp ~]#docker commit a0294a053f8c my_image/centos_httpd
d0938f54bfd62c2a108249c1f969aeab80be51fbbaee15b594004d4875327609

Create a container from the registered image and execute which to check httpd

[root@dlp ~]# docker run my_image/centos_httpd /usr/bin/which httpd

get the error

container_linux.go:235: starting container process caused “exec: “/usr/bin/whic h”: stat /usr/bin/which: no such file or directory”
/usr/bin/docker-current: Error response from daemon: oci runtime error: containe r_linux.go:235: starting container process caused “exec: “/usr/bin/which”: sta t /usr/bin/which: no such file or directory”.

[root@ns ~]# docker inspect my_image/centos_httpd
[
{
“Id”: “sha256:9a38d744e7233a3851bbcc4a8d1e121b6c3aede539c8c7256ac609a145ad33e2”,
“RepoTags”: [
“my_image/centos_httpd:latest”
],
“RepoDigests”: ,
“Parent”: “sha256:9f38484d220fa527b1fb19747638497179500a1bed8bf0498eb788229229e6e1”,
“Comment”: “”,
“Created”: “2019-07-05T04:09:04.022367221Z”,
“Container”: “c10fdbbee698a522d6ac929d973e500f140b25978c086972d0c46d59a8007502”,
“ContainerConfig”: {
“Hostname”: “c10fdbbee698”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: true,
“AttachStderr”: true,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/bin/bash”,
“-c”,
“yum -y update; yum -y install httpd”
],
“Image”: “centos”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {
“org.label-schema.build-date”: “20190305”,
“org.label-schema.license”: “GPLv2”,
“org.label-schema.name”: “CentOS Base Image”,
“org.label-schema.schema-version”: “1.0”,
“org.label-schema.vendor”: “CentOS”
}
},
“DockerVersion”: “1.13.1”,
“Author”: “”,
“Config”: {
“Hostname”: “”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/bin/bash”,
“-c”,
“yum -y update; yum -y install httpd”
],
“Image”: “”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {
“org.label-schema.build-date”: “20190305”,
“org.label-schema.license”: “GPLv2”,
“org.label-schema.name”: “CentOS Base Image”,
“org.label-schema.schema-version”: “1.0”,
“org.label-schema.vendor”: “CentOS”
}
},
“Architecture”: “amd64”,
“Os”: “linux”,
“Size”: 440272350,
“VirtualSize”: 440272350,
“GraphDriver”: {
“Name”: “overlay2”,
“Data”: {
“LowerDir”: “/var/lib/docker/overlay2/8cf04317ed7b1d523f3a15c7ae1ee2b19e91a3aeec4da14dc7f05fae8f7844be/diff”,
“MergedDir”: “/var/lib/docker/overlay2/78874f6401d21ac83f2322b67c070c418da63fc26f5656cd5e90f9fb164e3566/merged”,
“UpperDir”: “/var/lib/docker/overlay2/78874f6401d21ac83f2322b67c070c418da63fc26f5656cd5e90f9fb164e3566/diff”,
“WorkDir”: “/var/lib/docker/overlay2/78874f6401d21ac83f2322b67c070c418da63fc26f5656cd5e90f9fb164e3566/work”
}
},
“RootFS”: {
“Type”: “layers”,
“Layers”: [
“sha256:d69483a6face4499acb974449d1303591fcbb5cdce5420f36f8a6607bda11854”,
“sha256:4a6709365418c8f3dbb94bc18e9fdda281cb29dcd177987c48553b728353a0ad”
]
}
}
]

Why do you start it with “/usr/bin/which” ?
These base images are really slim, and may not contain all the commands that you would find in a normal centos image

Dear,
Than which command can i use to run the container.

Try something like:
docker run my_image/centos_httpd httpd -DFOREGROUND

Are you doing this because you’re trying to learn? because there is a ton of apache images out there :slight_smile:

1 Like

Yes, I have started learning docker.Can you guide me to where to start and follow which instructor videos.