Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I tried dockerizing my Laravel site and couldn't get it to work after multiple days. :(
Eventually just gave up. -
epse36585yI have a semi-popular open source project that is deployed using docker-compose... When it doesn't break its nicer than having to set up gunicorn and nginx and god knows what else just to test, but Holy hell is it a nightmare to maintain
-
-
Once you get it ull enjoy it, especially for deployment, it's a matter of running docker compose file and it will setup rest of requirements.
Consider learning docker as one of ur bash scripts u wrote that does routine stuff for you? You spend time writing it but saves u hours of useless routine.
And the best of all, in real world, u stop currently running stable version and push new version to live server, of new one sucked? Stop it, run older container and system back online in no time (assuming it takes little time to start up) -
@gitpush Fun thing is that I'm already stuck on getting my project running through php with specific extensions; pecl compilation seems to fail with a non descriptive error rendering it useless already 😅
-
Wack61915yFor PHP, you can take a look at https://github.com/thecodingmachine... ex. Use them as base image...
For an example docker-compose setup, https://phpdocker.io/generator might be of interest -
@Wack Interesting! I just built an image thinking it was going well but apparently I'm doing something wrong and I don't understand the online explanations a single bit 😅
-
There are free IBM courses for docker, I liked then so far. Since I did them I use docker for everything 😂
-
@linuxxx I'll throw in another wrench in the cog here... You need something to set up your swarm nodes as well. Check out Terraform. Infrastructure as Code, total sweetnes. If you use VMware vCenter, AWS, Open Stack, Virtual Box or what ever, they have an adapter for hooking up to their respective APIs. Just define what you need resourcse wise, how many instances of each, networking and what ever you need.
Happy trails! 😊 -
@RagingCodeChimp I still haven't figured it out. Got a simple php application and need to fucking dockerize it but I just don't see what I'm doing wrong.
-
@linuxxx the base image is prebuild php-fpm on nginx with sockets? Or homebrew?
-
Wack61915yTo get to the commandline within a container:
`docker ps` (to see all currently running containers)
`docker exec -it <id> /bin/bash` the I'd you get from docker ps, I think the first value for each. If your image is based in alpine, there usually is no bash, but you can use /bin/sh usually...
If you don't see all containers you're expecting in the docker ps, try to Find out, why some aren't showing up. -
@RagingCodeChimp I can't easily put those online without showing the entire project too badly.
Managed to get stuff to run! Two issues/questions left:
- application directory is mounted to the right local folder; will git pulls also make the container run the newly pulled code right away?
- how on earth would I let the application image access the hosts databases? -
Wack61915yTo pull updated images from the registry, use `docker-compose pull` (note this will update ALL images, if you use ex. MariaDB:latest it will get updated too! Either specify the version or specify in the docker-compose pull, which images to pull, or use `docker pull` and pull only those you want)
Next you'll need to restart to apply the update. The simplest solution would be `docker-compose down; docker-compose up -d`, however this will have a small downtime. You can use rolling updates with swarm: https://docs.docker.com/engine/...
About your question of passing a host DB to the container. The simplest answer is to simply mount the socket from Host to container... Ex. `/var/run/mysqld:/var/run/mysqld` and call it a Day.
Another option is to use IP based access: https://nickjanetakis.com/blog/... note: starting with docker 18.03 you can also use `host.docker.internal` as special domain, which will resolve to the hosts ip (https://stackoverflow.com/a/...)... Since you're using swarm, I'm not sure if this is what you want as there are potentially multiple hosts... -
@Wack i would strongly advise against those two db suggestions. The former may expose you to runtime issues, and the latter defeats the whole purpose of microservice architecture. In my opinion, the best and most secure way to do this would be to include a mysql service container (here's the official one: https://hub.docker.com/_/mysql) and then follow their directions on how to mount JUST YOUR DATA directory into the container, make a new user with access only to that dir, and then make calls to that service inside the swarm. This way you have an isolated service with your data in tact and you're not running the db as root.
Let me know if you have any questions, but this is pretty standard procedure. If you wanted to make the mysql image more secure i would grab an apparmor profile for it or/and an SElinux policy for it, but not running in the container as root should be sufficient. -
Wack61915y@arcsector I didn't say they're best practice and agree with your suggestion, however this is how I'd so it with the restriction that the DB has to run on the host and not in a container.
-
@arcsector I could, but I'm hardly familiar with docker yet so the chance of fucking something up is high for me right now.
Also, I just prefer the database to be on the host system as for now as many more applications depend on this and I don't have time to reconfigure the mongo part at the moment.
"Let's create a docker-swarm cluster thingy for this application with horizontal scaling to learn docker and run this application better!"
This stuff is so overwhelming and I don't understand half of how to possibly set this up 😅
rant