Docker container with Centos as base image is not running - docker

I had created the Docker container for RabbitMQ using the Following Docker File, But not able to run the Container, It's automatically stops.
Docker File
FROM centos:centos7
RUN yum -y update
RUN yum -y install wget
RUN wget https://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el6.x86_64.rpm
RUN yum -y install erlang-18.2-1.el6.x86_64.rpm
RUN wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.9/rabbitmq-server-3.6.9-1.el7.noarch.rpm
RUN yum -y install rabbitmq-server-3.6.9-1.el7.noarch.rpm
EXPOSE 15672
EXPOSE 5672
RUN rabbitmq-plugins enable rabbitmq_management
CMD /usr/sbin/rabbitmq-server -detached
Docker build Command
docker build -t rabbit .
Docker run command
docker run -d -p 15672:15672 rabbit
Container starts but's its exit's after a second
Thanks in advance

Related

why docker container id not coming up when it is running?

I have a docker file with entrypoint script as below
FROM centos:latest
MAINTAINER “HV"
#Add Environment variables here
ENV container docker
#Add Prerquisites
RUN yum install wget -y
RUN yum install unzip -y
RUN yum install make -y
RUN yum install sudo -y
RUN yum install libtool-ltdl -y
RUN yum install python3 python3-pip -y
#Install Git
RUN mkdir -p /home/Test/
RUN yum install git -y
#Copy Entrypoint script
COPY ilab_entrypoint.sh /usr/local/bin/
ENTRYPOINT ["ilab_entrypoint.sh"]
CMD ["/usr/sbin/init"]
#!/bin/bash
set -e
git clone git_url
exec "$#"
So i could build and run the container i don;t see the id when i am inside the container,
example,
when i run the docker container i can enter it but it remains as same localhost but no id
root#centos8-test:[/home/Test]: docker exec -it 3c2b5973f5c0 bash
[root#centos8-test /]#
it should be running as below instead
[root#3c2b5973f5c0 /]#
This is not related to the script, if you want to change the hostname you can specify it in the run command:
$ docker run --rm -it python:3.9 bash
root#2d97c319abcf:/# exit
exit
$ docker run --rm -it --hostname some-host python:3.9 bash
root#some-host:/# exit
exit

Docker Container Not Starting for create docker file

AM completely new to Docker, now am trying to create a container for tomact from ubuntu base image & written a docker file acoding to it:
From ubuntu
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install wget -y
RUN apt-get install openjdk-8-jdk -y
RUN mkdir /usr/local/tomcat
RUN wget https://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.61/bin/apache-tomcat-8.5.61.tar.gz
RUN tar xvzf apache-tomcat-8.5.61.tar.gz
RUN mv apache-tomcat-8.5.61 /usr/local/tomcat/
#MD ./usr/local/tomcat/apache-tomcat-8.5.61/bin/catlina.sh run
EXPOSE 8080
RUN /usr/local/tomcat/apache-tomcat-8.5.61/bin/catlina.sh run
Created Docker image for the respective docker file using:
docker build -t [filename] .
Tried to start the container using: docker run -itd --name my-con -p 8080:8080
but the container is not starting & the container is listed in stopped container
Cn any one help me fixing this issue
Thanks.
try this in last line:
CMD ["/usr/local/tomcat/bin/catalina.sh","run"]

Use rabbitmq in Ubuntu 16.04 inside Docker

I am new to Docker. I want to create an image in Docker which to run a microservice that needs RabbitMQ and Redis. For Redis, I include redis in the line RUN apt-get install -y python python-pip libsasl2-dev libmysqlclient-dev redis-server wget inside Dockerfile. To install RabbitMQ, I use
RUN apt-get update
RUN apt-get -y -q --allow-unauthenticated install rabbitmq-server
RUN /usr/sbin/rabbitmq-plugins enable rabbitmq_management
RUN echo "[{rabbit, [{loopback_users, []}]}]." >
/etc/rabbitmq/rabbitmq.config
# Port to expose
EXPOSE 9060 5672 15672
However, the rabbitmq server is not running in default which will prompt error when I run the built image. I have a line ENTRYPOINT ["/docker-entrypoint.sh"] to run my microservice. How can I run the rabbitMQ service from Dockerfile?

Build and run container but there is no container

I have a dockerfile look like this
FROM ubuntu
MAINTAINER abc <abc.yur#gmail.com>
RUN apt-get update
RUN apt-get install nano
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository ppa:longsleep/golang-backports
RUN apt-get update
RUN apt-get -y install golang-go git
RUN mkdir /work
ENV GOPATH=/work
RUN go get github.com/abc/golang
RUN go build github.com/abc/golang
CMD /golang -addr $ADDR -workers $WORKERS
So I want to build and run container but after the building (docker build .) I can not run this container. So when I am running docker ps -a or docker ps there is not container to run
docker build .
This creates the image and not a container. You need to use
docker images
To get the list of images.
docker ps will show when you run a container using something like below
docker run -d <image>

adding a command docker image

I have built an image using these steps:
download adminer package
wget https://www.adminer.org/static/download/4.2.4/adminer-4.2.4-en.php
mv adminer-4.2.4-en.php adminer.php
create docker file
vi dockerfile
FROM ubuntu
RUN apt-get -y install apache2 php5 php5-curl php5-cli php5-mysql php5-gd mysql-client mysql-server
RUN apt-get -y install postgresql postgresql-contrib
RUN apt-get -y install php5-pgsql
COPY adminer.php /var/www/html/
RUN chmod -R 777 /var/www/html/
build and run
docker build -t shantanuo/adminer1 .
docker run -i -t --rm -p 80:80 --name adminer1 shantanuo/adminer1
I need to run this command to start apache once I am inside the container.
sudo service apache2 start
How do I include this command in the dockerfile? (Build failed after adding CMD for this purpose.)
Is there any other (better) way of installing adminer.php package?
Is it possible to reduce the size of this image?
What you do is opening an interactive bash session and try to start a server.
It would be better if you started your same image in detached mode (-d) instead of -it, and let apache runs.
For that, as commented, you need to start FROM httpd:2.4 which:
has a Dockerfile starting by default apache
has a httpd-foreground scripts launching apache server in foreground.
Even better would be to use a PHP docker image:
FROM php:5.6-apache
That way, you don't even have to install apache or php. You just copy your php application.
Then, if you need to, you can still open a bash session with:
docker exec -it <yourContainer> bash

Resources