Yesterday I decided to learn docker and use it for a prestashop project so I created a docker-compose.yml
my goal was to run a prestashop with a phpmyadmin and mysql all linked together.
Before leaving yesterday I didn't want to lose everything I had done so I ran a docker save
and a docker commit
, so I thought whenever I come back I can just run the save I made and run it without losing anything (like a snapshot).
Everything was working, containers were running and today when I try to run a docker ps -a
I have an empty output. However my project is still working on localhost:8080
for prestashop and localhost:8081
for my phpmyadmin.
How could I find back the containers and also save them so I can use them on another computer?
docker-compose.yml
:
version: "3.8"
services:
db:
image: mysql:latest
command: --default-authentication-plugin=mysql_native_password
container_name: db
restart: always
volumes:
- db-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
networks:
- dev
phpmyadmin:
image: phpmyadmin:latest
container_name: phpmyadmin
restart: always
depends_on:
- db
ports:
- 8081:80
environment:
PMA_HOST: db
networks:
- dev
apache:
build: php
container_name: prestashop
ports:
- 8080:80
volumes:
- ./php/vhosts:/etc/apache2/sites-enabled
- ./:/var/www/html
restart: always
networks:
- dev
networks:
dev:
volumes:
db-data:
Dockerfile
:
FROM php:7.4-apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN apt-get update
&& apt-get install -y --no-install-recommends locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev;
RUN echo "en_US.UTF8 UTF8" > /etc/locale.gen &&
echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen &&
locale-gen
RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls &&
mv composer.phar /usr/local/bin/composer
RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo pdo_mysql gd opcache intl zip calendar dom mbstring zip gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN a2enmod rewrite && service apache2 restart
RUN chown -R www-data:w
Output for docker images
:
REPOSITORY TAG IMAGE ID CREATED SIZE
prestadock_apache latest 740c640530f3 2 days ago 657MB
phpmyadmin latest f7fd780fedba 7 days ago 469MB
php 7.4-apache 899ab23566b7 7 days ago 414MB
mysql latest c8562eaf9d81 10 days ago 546MB
Output for docker network ls
NETWORK ID NAME DRIVER SCOPE
e03870bf5fec bridge bridge local
63cfaacfbb2e chronopiles bridge local
c23a0b85edb9 host host local
1ae1b68b12c0 none null local
1e8010db79e3 prestadock_dev bridge local
590b5e949037 prestashop bridge local
question from:
https://stackoverflow.com/questions/65951412/docker-working-on-localhost-but-have-an-empty-containers-running-list 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…