phpearth / docker-php

🐳 Docker For PHP developers - Docker images with PHP, Nginx, OpenLiteSpeed, Apache, Lighttpd, and Alpine
https://docs.php.earth/docker
MIT License
261 stars 80 forks source link

How I can get shell back in current docker? #21

Closed KingYes closed 5 years ago

KingYes commented 5 years ago

This is my output about this:

$ kubectl exec -it dockername-XXX-YYY -- /bin/bash
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory"

command terminated with exit code 126

It's in Kubernetes, but in local docker its a same.

Thanks!

petk commented 5 years ago

Probably because there is no bash on that docker container. Many images, including these use only POSIX shell:

kubectl exec -it dockername-XXX-YYY -- /bin/sh
KingYes commented 5 years ago

Hey,

Can you change the base OS you use in this docker?

I need apt-get for example to install extra packages..

insekticid commented 5 years ago

use apk add and do not forget to run apk update before. have a look for example to my dockerized piwik repo on github

On Tue, 24 Jul 2018 at 14:32, Yakir Sitbon notifications@github.com wrote:

Hey,

Can you change the base OS you use in this docker?

I need apt-get for example to install extra packages..

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phpearth/docker-php/issues/21#issuecomment-407390084, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK0vKEo_tNdgqwtD1zf4qL-PwQn5iITks5uJxPvgaJpZM4VcJUt .

petk commented 5 years ago

Alpine's packages: https://pkgs.alpinelinux.org/packages

To use a Debian based distribution, yes, a completely new Dockerfile is required for a base image. Otherwise, Alpine today provides most things already except software that require glibc specifically. Alpine is based on musl (the system C headers and stuff) and that causes some incompatibilities with software that is not made portable enough yet.

KingYes commented 5 years ago

Okay, thanks !

But for now I can't get mysqli ext to work. In this code:

var_dump(function_exists('mysqli_connect'));

I get false.

My docker file is:

FROM phpearth/php:7.2-nginx

RUN apk add --no-cache php7.2-sodium php7.2-intl php7.2-pdo_mysql bash wget

What I miss?

petk commented 5 years ago

@KingYes

the php7.2-mysqli package...

KingYes commented 5 years ago

It's the same. Can you show your own docker for that?

Maybe need to reload the nginx after this package get installed?

petk commented 5 years ago
FROM phpearth/php:7.2-nginx

RUN apk add --no-cache php7.2-sodium php7.2-intl php7.2-pdo_mysql php7.2-mysqli bash wget

To build your customized Docker image:

docker build -t myvendor/myapp -f Dockerfile .  

To run Docker container from the built image:

docker run -it --rm myvendor/myapp php -r "var_dump(function_exists('mysqli_connect'));"

I think this should work ok... But we need to bump also PHP versions in the docker hub to have the latest PHP versions...

P.S: it might be that you need to refresh your image once you've installed a new package... Common issuee with Docker sometimes...

KingYes commented 5 years ago

If I run this docker by your example, I get "true". But the same docker in Kubernetes I get "false". :(

petk commented 5 years ago

I'll check it out, thanks for reporting then... Do you maybe have any direct steps to reproduce this?

KingYes commented 5 years ago

Okay, it's like a cache. I clear the cache from my images, and it's working. Thank you !

Sorry about that.

petk commented 5 years ago

In case of issues, just ask.. Thanks.

KingYes commented 5 years ago

Sorry for that, but what is the best way to install SSL on this docker?

petk commented 5 years ago

Certbot via a separate image.