Difficulties in configuration

I’m using docker toolbox
docker version 18.03.0-ce
my windows is 10

I’m having trouble setting up a scenario.

1- I need to run a linux (can be ubuntu), with php 7.1, apache and mysql,
2 - I need to configure my environment with hash, because my code uses the ioncube and I need to install linux to place “ioncube_loader_lin_7.1.so” in the path identified in php info extension_dir

Currently:
I made a test creating a dockerfile to create a run an image I found on the internet: FROM tecadmin / ubuntu-ssh: 16.04 where it updates and installs apache2

I do not know if this is the best way but it’s the one that works for me

FROM tecadmin/ubuntu-ssh:16.04

RUN echo "init \n"

RUN apt-get update \

&& apt-get install -y apache2

RUN echo "End \n"

COPY public/ /var/www/html/

WORKDIR /var/www/html

CMD ["apachectl", "-D", "FOREGROUND"]

EXPOSE 80

87/5000

Then I created a docker-compose with mysql and an apache image to test and is running:

 version: '3'
services:
  db:
     image: mysql
     container_name: mysql_db
     restart: always
     environment:
        - MYSQL_ROOT_PASSWORD="secret"
  web:
    image: apache
    build: ./
    depends_on:
       - db
    container_name: apache_web
    restart: always
    ports:
      - "8080:80"

I am lost because there are many images on the internet and I do not know which one to use in my case for a better result.

For it seems that each image has a form of configuration, and this displays several types of errors, distinct, some with volumes, others related to displaying the result in the url.

Hi

Always check https://hub.docker.com before you make your own image, maybe someone else have spend time creating what you are trying to achieve.

Maybe you can use this: https://hub.docker.com/r/atsu666/ioncube
?

thanks Terpz!

But my concern is to master the concept of the thing, so I am creating.

Some of my difficulties, for example, in the code above:
If I create a volume in docker-compose by pointing my root folder to / var / www / html / folder when building the “docker-compose build” image and running docker-compose up, the url of this path stops working, http://192.168.99.100/ displays empty folder, even having an index.html.

These are things I do not understand, I figured I could use volumes to transfer from my machine to the container.

When you say “root folder”, does this folder contain the web files?
because when you put in the web files, in the build process, and you decide to mount the folder in the container afterwards, the /var/www/html will be empty, IF the folder you mount on your host, is empty

I not understend.

this my docker-compose.yml:

version: '3'
services:
  db:
     image: mysql
     container_name: mysql_db
     restart: always
     environment:
        - MYSQL_ROOT_PASSWORD="secret"
  web:
    image: apache
    build: ./
    depends_on:
       - db
    container_name: apache_web
    restart: always
    ports:
      - "8080:80"
    volumes:
      -  ./public:/var/www/html/

my public contents:
index.html and comando.html

When execute “docker-compose build” and “docker-compose up -d” im my brownse http://192.168.99.100:8080/index.html view “not found”

If i have the following:

├── docker-compose.yml
├── dockerfile
└── public
    └── index.html

the dockerfile is the same as yours, and docker-compose.yml is the same, except for the mysql part.

and i just go: “docker-compose up -d”, it works fine, i can see my index.html

remove the your Dockerfile this:
COPY public/ /var/www/html/

and view if docker-compose volumes is worked

I did do that, and it works fine :slight_smile:

just to be sure, what happends if you visit: http://localhost:8080 ?

I modified it to: ports “80:80” not to execute 192.168.99.100:8080

Now when I execute docker build and

db uses an image, skipping
web uses an image, skipping

i not understend…
today is not my day

the browser is cached, I have to enter the private one to see the result

now i dont execute build…

you dont need to build every time.
once you build your image, you dont need to touch it, unless you are making updates to it.
To see a list of your images: docker images

i execute docker images

and list very images:

REPOSITORY TAG IMAGE ID CREATED SIZE
f25ed8361486 2 hours ago 326MB
apache latest 9c2d6fa21e89 2 hours ago 326MB
27763c422963 2 hours ago 326MB
f215b9d5f3b6 3 hours ago 326MB
b737792a39f0 20 hours ago

so eecuted
docker stop (docker ps -a -q) docker rm (docker ps -a -q)

and

docker rmi image $(docker images -a -q)

and executed docker-machine stop and start

my docker-machine env

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\andre\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
 Run this command to configure your shell:
 eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

but docker-compose build

“db uses an image, skipping
web uses an image, skipping”

my docker images is empty now

so i execute docker-compose up -d

and now im my download process:

Pulling web (apache:latest)...
ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

Continue with the new image? [yN]y
Pulling web (apache:latest)...
ERROR: pull access denied for apache, repository does not exist or may require 'docker login'

Now I can not recreate the first situation

any changes to your compose file or dockerfile ?
i could be that the "build: " tag is missing from the compose file

my dockerfile:

FROM tecadmin/ubuntu-ssh:16.04

RUN apt-get update \

&& apt-get install -y apache2

WORKDIR /var/www/html

CMD ["apachectl", "-D", "FOREGROUND"]

EXPOSE 80

my docker-compose:

version: '3'
services:
  db:
     image: mysql
     container_name: mysql_db
     restart: always
     environment:
        - MYSQL_ROOT_PASSWORD="secret"
  web:
    image: apache
    depends_on:
       - db
    container_name: apache_web
    restart: always
    ports:
      - "80:80"
    volumes: 
      - ./public:/var/www/html/

Now docker-compose does not understand the web image: apache, it looks like it is not running dockerfile …

because you removed: "build: ./ " from the web part in the compose file

i executed “docker-compose build” and apply images

and i executed “docker-compose up -d” and

Creating mysql_db … done
Creating apache_web … done

but in my brownse:

: http: // 192.168.99.100/

index-of

instead of “./public” can you try and put in the full path (type pwd in shell)

My pwd:
/c/xampp7.2/htdocs/docker

my volumes:

volumes: 
      - /c/xampp7.2/htdocs/docker/public:/var/www/html/

i executed ‘docker-compose up -d’

mysql_db is up-to-date
apache_web is up-to-date

and “index of /” persist

follow my directory in red:
rules-folder-new

i created one test the volumes:

dummy-log-parser:
  image: alpine:latest
  volumes:
    - /online/agora.log:/online/agora.log:ro
  command:
    - "sleep"
    - "3600"

and access file:

docker exec -it cd20ac4a7a3d sh

# cd online
# cat agora.log
cat: read error: Is a directory
cd agora.log/
# online/agora.log/ 

so, my volumes create folder and not file?

I found a solution,

As I’m using the toolbox, it depends on the virtualbox to run, inside it configures which folder should be shared, in my case it was c / Users, I just needed to choke my project here and I managed to make the volumes work.

Thanks for help :wink:

1 Like