Restarting machines in a docker swarm on AWS - amazon-web-services

I have successfully created a docker swarm of 5 VMs on AWS using docker-machine. I stopped one VM using the command
docker-machine stop aws01 and then I tried docker-machine start aws01
but Immediately I get an error
Error checking TLS connection: Error checking and/or regenerating the certs:
There was an error validating certificates for host "5x.20x.23x.10x:2376":
x509: certificate is valid for 5x.2x.17x.25x, not 5x.20x.23x.10x
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which will stop running containers
Is really stoping and starting a container such a big deal that everytime I do this, I need to regenerate certs?
Is there a low impact way of stoping and starting my machines.
This never happened to me when I was using a local virtualbox VM for docker. This started only when I created docker machine on AWS.
As you can see that since I have 5 machines, starting and stopping is a big pain for me because I need to regenerate certs for all machines everytime I stop them? Obviously since its AWS I can't keep my machines running all the time.

Related

How to keep the application on when ec2 get stopped?

what I did is I deployed Tomcat application in EC2 but I install and configure it previously before launching the ec2.
basically, when your machine of app comes up, it should have the tomcat application already deployed in it
without running the shell commands manually to install and configure tomcat.
Right now the problem is when I stopped the ec2 and start it again the tomcat application was not pop up when I hit the IP.
can you please tell me how to solve this problem?
If I understood correctly, you need to run a set of commands on instance startup to configure your application/server.
You can do this with a user data script. User data is executed at launch, and you can configure it to run on restarts as well.
If I understood right, you want your tomcat to be started everytime you restart your server.
You can configure the tomcat as a linux service and enable that service so that it will start tomcat every time your system reboots. This way, you don't have to start tomcat manually each time system reboots.
Reference: https://www.digitalocean.com/community/tutorials/install-tomcat-on-linux

AWS System Manager Run Command on EC2 Failes

I'm running a fastapi server on ec2 ubuntu. Everything work fine when I ssh in to ec2 and run commands, but I want the server to be running when my local machine is off.
So, I tried AWS System manager's run command. The connection looks fine but when I cd to the server code and run ls it outputs nothing. Also, when I do poetry run python main.py in the server folder, which works totally perfect when I ssh in to the server from my local machine, it says poetry: not found.
Why is this happening. And is there another way I can run my server while being able to turn off my local machine.
There is not any kind of relation between your machine and your server in the cloud, and your ec2 its still alive and runs your services whenever you want

Connect to a container running in Docker (Redis) from Cloud Run Emulator locally

I'm making local cloud run services with the Cloud Code plugin to Intellij (PyCharm) but the locally deployed service cannot connect to the redis instance running in Docker:
redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
I can connect to the locally running redis instance from a python shell, it's just the cloud run service running in minikube/docker that cannot seem to connect to it.
Any ideas?
Edit since people are suggesting completely unrelated posts - The locally running Cloud Run instance makes use of Docker and Minikube to run, and is automatically configured by Cloud Code for Intellij. I suspect that Cloud Code for intellij puts Cloud Run instances into an environment that cannot access services running on MacOS localhost (but can access the Internet), which is why I tagged those specific items in the post. Please limit suggestions to ones that takes these items into account.
If you check Docker network using:
docker network list
You'll see a network called cloud-run-dev-internal. You need to connect your Redis container to that network. To do that, run this command (This instruction assumes that your container name is some-redis):
docker network connect cloud-run-dev-internal some-redis
Double check that your container is connected to the network:
docker network inspect cloud-run-dev-internal
Then connect to Redis Host using the container name:
import redis
...
redis_host = os.environ.get('REDISHOST', 'some-redis')
redis_port = int(os.environ.get('REDISPORT', 6379))
redis_client = redis.StrictRedis(host=redis_host, port=redis_port)

Elastic Beanstalk not deploying and cannot find error in error logs

I am having an issue getting my application to deploy on the elastic beanstalk. It works on my local machine flawlessly however when I try to deploy to beanstalk it fails and rolls back to the sample application. Then when I check the error.log file it is empty. Also when I check the node.js file the only output is
> Elastic-Beanstalk-Sample-App#0.0.1 start /var/app/current
> node app.js
Server running at http://127.0.0.1:8081/
I don't understand how to find the error it sends when deploying to the server. Where should I be looking?
The reason it was deleting my logs is I had rolling with additional batch enabled. Thereby deleting my logs on rollback. As far as the error was concerned it was an error in my code that caused it to require a module that didn't exist
It appears that you are running the app with the HOST set to localhost (127.0.0.1). The localhost is accessible only to internal processes on your Beanstalk instance. Change the host to 0.0.0.0 so that the app can be accessed from other IP addresses.

sonarqube docker container's setting is lost after stopping ec2 instance

I am running Jenkins server on which sonarqube docker container is running but we stop this server once build is done hence the sonarqube container's setting is lost, is there any way for it.
Please suggest me the proper way to handle this scenario.
I am running Jenkins on Ubuntu ec2 instance