LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Containers (https://www.linuxquestions.org/questions/linux-containers-122/)
-   -   container (https://www.linuxquestions.org/questions/linux-containers-122/container-4175685838/)

yangyiin 11-26-2020 07:38 AM

container
 
hi,
i like to deploy http inside of docker with ansible.
[code]
more Dockerfile
FROM centos
RUN /usr/bin/yum -y install httpd
COPY index.html /var/www/html/index.html
COPY run.sh run.sh
CMD ./run.sh

more run.sh
exec /sr/sbin/httpd -D FOREGROUND

run.sh is executable

then
docker build -t image .
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
image latest e4d86712928a

more yd.yml
- name: test
hosts: localhost
tasks:
- name: test4
docker_container:
name: test54
image: image
state: started
ports:
- "8080:80"
tty: true
detach: true
ansible-playbook yd.yml

docker ps -a
CONTAINER ID IMAGE COMMAND
e12c1a9bf934 image "/bin/sh -c ./run.sh" Exited (127) test54

Why this container exited?

boughtonp 11-26-2020 08:41 AM


 
You've not use code tags properly, so it's difficult to parse, but the relevant part is this:
Code:

e12c1a9bf934 image "/bin/sh -c ./run.sh" Exited (127) test54
The 127 is an exit status which indicates "If a command is not found, the child process created to execute it returns a status of 127."

It's probably because you've got this in run.sh: "/sr/sbin/httpd -D FOREGROUND" - there is a missing u before sr so it can't find it.


berndbausch 11-26-2020 08:49 AM

From the Dockerfile reference:
Quote:

COPY has two forms:
Code:

COPY [--chown=<user>:<group>] <src>... <dest>
COPY [--chown=<user>:<group>] ["<src>",... "<dest>"]

...

The <dest> is an absolute path, or a path relative to WORKDIR, into which the source will be copied inside the destination container.
In your case, <dest> is relative, but you have no WORKDIR directive. I don't know what happens in this case, but my guess is that it's not defined.

laundry 04-30-2021 03:27 PM

One thing to also note, is that you will need an 'EXPOSE' command in your dockerfile, to allow that port to be exposed from the image itself.


All times are GMT -5. The time now is 12:47 PM.