skip to Main Content

First of all, I would like to say that I’m new to Docker and all that is around it.

I have been wanting to make a container where I have Apache, php and Firebird installed. So far, so good ; everything seems to work and I can get my default page when I type in my Internet search bar my ip address and :8080. I do so by first starting my container like this :

docker run -p 8080:80 -d apps

Where "apps" is the name of my container.

I have achieved this with my Dockerfile, which looks like this (it might be a bit messy, still learning the good practices !) :

# Download of base image - ubuntu 20.04
FROM ubuntu:20.04

# Updating/upgrading
RUN apt-get update -y && apt-get upgrade -y

# Installing apache2, php and firebird with modules
RUN DEBIAN_FRONTEND="noninteractive" apt-get install apache2 php libapache2-mod-php -y && 
    apt-get install php-curl php-gd php-intl php-json php-mbstring php-xml php-zip -y && 
    DEBIAN_FRONTEND="noninteractive" apt-get install firebird3.0-server -y && apt-get install firebird->

# Start up apache in foreground by default
CMD /usr/sbin/apache2 -D FOREGROUND
ENTRYPOINT service apache2 restart && /bin/bash

# Expose apache
EXPOSE 80

Now, my idea was to export this container to another computer and try the same thing. I have followed a few tutorials and got to import my container on the new machine. My problem here is that somehow, the command I previously used doesn’t work ; it shows me this error :

docker: Error response from daemon: No command specified.
See 'docker run --help'.

Which is odd, because it works just fine on the other machine. I also did this command, WHICH WORKS :

docker run -i -t -p 8080:80 apps /bin/bash

This one works alright, but I don’t want to have to access the bash everytime I want my Apache page to load. I would want my container to run without me having to get in my container, if that makes sense.

In my opinion, it probably comes from the fact that I only loaded the container, and not the image used to build it (maybe a bad practice? Couldn’t find anything about it on google).

Here is my setup just in case —

On the first machine (which is the one where I created the image and the container) :

  • Ubuntu 20.04 LTS
  • Apache/2.4.41
  • Docker 19.03.8

On the other machine which I’m trying to make my container work :

  • Ubuntu 18.04 LTS
  • Apache/2.4.29
  • Docker 19.03.6

Thank you for your patience and time !

2

Answers


  1. Where "apps" is the name of my container. <- This statement is incorrect and perhaps the misunderstood concept that leads you to the problem.

    apps is the name of the image, not the name of the container. On the host on which you can run the container, you must have built that image from the Dockerfile that you shared using the command:

    docker build -t apps .
    

    Copy the Dockerfile on the host where you cannot run the container, built the image in-there as well and try again running the container.

    Login or Signup to reply.
  2. apps is your docker image, if you want to give name for your container you can specify –name in the run command ie,

    docker run --name container_name -p 8080:80 -d apps
    

    You can use sudo docker save -o apps.tar apps to create a tar file of the image
    then change the root permission of the tar file sudo chmod 777 apps.tar

    Copy this tar file to the other system you want to try, then

    sudo docker load --input apps.tar
    

    This will load the image, then you can use the previous command to start the container

    docker run -p 8080:80 -d apps
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search