LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 11-26-2020, 07:38 AM   #1
yangyiin
Member
 
Registered: Nov 2018
Posts: 44

Rep: Reputation: Disabled
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?
 
Old 11-26-2020, 08:41 AM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,600

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

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.


Last edited by boughtonp; 11-26-2020 at 08:45 AM.
 
1 members found this post helpful.
Old 11-26-2020, 08:49 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
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.

Last edited by berndbausch; 11-26-2020 at 08:50 AM.
 
Old 04-30-2021, 03:27 PM   #4
laundry
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Meet Super Container OS, a Debian-Based Live Distro with a Built-In Container Engine LXer Syndicated Linux News 0 08-04-2020 11:24 AM
linux container host os and container os question jzoudavy Linux - Newbie 1 09-01-2015 05:21 AM
LXer: Inside the Open Container Project: How Docker plans to unite the container market LXer Syndicated Linux News 0 06-23-2015 04:30 AM
Encrypted virtual drive/container magkakape Linux - Software 2 06-22-2004 07:27 AM
Qworkspace? and container? kalleanka Programming 0 03-01-2004 05:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration