Docker Community Forums

Share and learn in the Docker community.

Execute 'docker ps --format "{{.Names}}: {{.Ports}}"' in php container + apt-get update not working

Hallo Forum - im hoping you guys can help me …
Im running a OMV / Debian 9 server with nginx installed (OMV plugin) and i want to switch it to Docker.
So my skills it properly beginner…

PROBLEM 1)
I have installed php 7.2.2-apache with docker-compose.yml :

version: ‘3’
networks:
default:
external:
name: web
services:
db:
image: mysql:5.7
container_name: mysqldb
environment:
MYSQL_ROOT_PASSWORD: XXX
MYSQL_DATABASE: XXX
MYSQL_USER: XXX
MYSQL_PASSWORD: XXX
ports:
- “3306:3306”
restart: unless-stopped
web:
image: php:7.2.2-apache
container_name: web
privileged: true
depends_on:
- db
volumes:
- /srv/dev-disk-by-label-www/www:/var/www/html/
restart: unless-stopped
ports:
- “8100:80”
stdin_open: true
tty: true
labels:
- traefik.backend=www
- traefik.frontend.rule=Host:XXX
- traefik.docker.network=web
- traefik.port=80
- traefik.enable=true

So this part is working , BUT…
I have a couple scripts (.sh) that is executed when i log on to my webpage and here comes the problem
One of my script is :
PHP:
shell_exec(‘bash /var/www/html/content/service/docker.sh’);

docker.sh:
#!/bin/sh
docker ps --format “{{.Names}}: {{.Ports}}” | sed ‘s/:.*>/:/’ | sed ‘s+, *8118/tcp++’ | sort > /var/www/html/content/service/docker.txt 2>&1

and this is not getting any results…
I have read that i need to map /var/run/docker.sock:/var/run/docker.sock
That didn’t work …
I have logged in to the container:
docker exec -ti web bash

and tried to run ‘docker ps’ but that returned:
bash: docker: command not found

PROBLEM 2)
i cant even run ‘apt-get update’ :
Err:1 http:/deb,debian,org/debian stretch InRelease
Temporary failure resolving ‘deb,debian,org’
Err:2 http:/security,debian,org stretch/updates InRelease
Temporary failure resolving ‘security,debian,org’
Err:3 http:/deb,debian,org/debian stretch-updates InRelease
Temporary failure resolving ‘deb,debian,org’
Reading package lists… Done
W: Failed to fetch http:/deb.debian.org/debian/dists/stretch/InRelease Temporary failure resolving ‘deb.debian,org’
W: Failed to fetch http:/deb.debian.org/debian/dists/stretch-updates/InRelease Temporary failure resolving ‘deb.debian,org’
W: Failed to fetch http:/security.debian.org/dists/stretch/updates/InRelease Temporary failure resolving ‘security.debian,org’
W: Some index files failed to download. They have been ignored, or old ones used instead.

I hope you guys can help or point me in the right direction

Any inputs is appreciated…