0

I tryied to run php:apache container. Then i apply the virtual host setting and exit the container bash and I used docker restart <containerid> but i couldn't start. Then i checked the logs with docker logs <containerid> and it says you have a syntax in 000-default.conf

Now that's my question: If i can't start the container how can i connect the container bash and open the 000-default.conf and fix the syntax error? Is there any other way for that?

Here is the log output:

C:\Users\Utku>docker logs bb
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Sat Mar 23 01:05:26.411235 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.16 configured -- resuming normal operations
[Sat Mar 23 01:05:26.411274 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Sat Mar 23 01:05:37.388586 2019] [autoindex:error] [pid 16] [client 172.17.0.1:40982] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
localhost:80 172.17.0.1 - - [23/Mar/2019:01:05:37 +0000] "GET / HTTP/1.1" 403 501 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
localhost:80 172.17.0.1 - - [23/Mar/2019:01:05:37 +0000] "GET /favicon.ico HTTP/1.1" 404 500 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
localhost:80 172.17.0.1 - - [23/Mar/2019:01:06:55 +0000] "GET / HTTP/1.1" 200 286 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"
[Sat Mar 23 01:07:53.847828 2019] [mpm_prefork:notice] [pid 1] AH00169: caught SIGTERM, shutting down
AH00526: Syntax error on line 35 of /etc/apache2/sites-enabled/000-default.conf:
Invalid command 'sadasd', perhaps misspelled or defined by a module not included in the server configuration
Utku Altaş
  • 118
  • 5
  • 1
    Possible duplicate of [How do I edit a file after I shell to a Docker container?](https://stackoverflow.com/questions/30853247/how-do-i-edit-a-file-after-i-shell-to-a-docker-container) – vfalcao Mar 23 '19 at 01:01
  • Please, post the exact error logged, in order to help us help you solve your problem. – vfalcao Mar 23 '19 at 01:02

2 Answers2

0

EDIT: docker cp should also works on stopped container, you can copy the config file out of the container, edit it, and copy back.

Yes, but you need to create an image from this container and run it:

  1. use docker ps -a to find the failed container's id, for example: d391b29f5526.
  2. run docker commit d391b29f5526 test-image to create a image from this container.
  3. docker run -it --entrypoint bash test-image and do your edit.
  4. commit the container created from step 3 to an image and run it.
tsl0922
  • 2,685
  • 1
  • 12
  • 6
0

Try the following:

docker cp bb:/etc/apache2/sites-enabled/000-default.conf /tmp/000-default.conf

now, edit your /tmp/000-default.conf (on your docker host) and remove this sadasd on your line 35, as said in the log;

after editing, copy back the file to the container:

docker cp /tmp/000-default.conf bb:/etc/apache2/sites-enabled/000-default.conf

If your conf files are error free, now you should be able to restart your container.

vfalcao
  • 332
  • 1
  • 3
  • 12