Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use docker for sqs locally

I am using AWS SQS in my project. I want to use this for local setup. For SQS purpose I have added dokcer_local on my project.

I have updated docker file with by adding this as suggested in the link.

FROM java:8

ADD https://s3-eu-west-1.amazonaws.com/softwaremill-public/elasticmq-server-0.13.8.jar /
COPY custom.conf /
ENTRYPOINT ["/usr/bin/java", "-Dconfig.file=custom.conf", "-jar", "/elasticmq-server-0.13.8.jar"]

EXPOSE 9324

CMD ["-help"]

When I execute command docker ps I get this on my screen

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
48e934fc6c43        mysql:5.7.16        "docker-entrypoint.s…"   24 minutes ago      Up 24 minutes       0.0.0.0:10612->3306/tcp   xyz_mysql_1
0af050bd3332        vsouza/sqs-local    "/usr/bin/java -Dcon…"   2 hours ago         Up 2 hours          0.0.0.0:9324->9324/tcp    wizardly_yalow

I have added entry for sqs in my docker-compose.yml file too as:

sqs:
    image: s12v/elasticmq
    ports:
    - "9324:9324".

Now I am unable to understand how to use the sqs on my console. after going in the shell of sqs using this command sudo docker exec -it 0af050bd3332 sh. When I try to list queue it is printing sh: 2: list-queues: not found error.

I have tried lots of things but nothing seems to work.

like image 539
Geek_To_Learn Avatar asked Jul 05 '18 07:07

Geek_To_Learn


People also ask

How to run SQL Server from a docker container?

We need to pull down the SQL Server docker image from the container registry with the following command: 2. Run the container Now that we have the sql server image locally, it’s time to run the container. SQL Server needs us to set 2 environment variables, first to Accept the EULA agreement, and secondly to set the SA password.

How to run localstack SQS on Docker using PowerShell?

Now that Docker is running on your PC, you need to startup PowerShell as an Administrator. Then you can paste the following command into PowerShell to get LocalStack SQS running (this is all one line): The first time you run this command, Docker will download the LocalStack software from the repository.

How to get Amazon SQS queue working locally with localstack for Docker?

In this post I’m going to show how to get Amazon’s SQS queue working locally using LocalStack for Docker. The first step is to download and install Docker. If you don’t have Docker installed on your Windows PC, you’ll need to search for the docker download. Look for “docker engine community for windows” to find the right one.

Can fake-SQS create a queue inside a docker container?

.... This should be all to at least see the queue create inside your Fake-SQS running inside your docker container which is running on http://localhost:9324. Here is the list of API calls that you can make for this queue.


2 Answers

What your Dockerfile is doing is creating an ElasticMQ server. The latter is a "message queue system" which is compatible with SQS. So, you can use it the same exact way you use SQS, except you have to change the endpoint parameter when using the AWS CLI or SDK.

Let's do an interactive example here:

  1. Run the following Docker command:
$ docker run -p 9324:9324 -p 9325:9325 softwaremill/elasticmq
  1. Now, in another tab, execute the following AWS CLI command (notice the --endpoint parameter pointing to the locally running ElasticMQ server created above):
$ aws --region=us-west-2 --endpoint=http://localhost:9324 sqs list-queues

The result should be empty.

  1. Now try to create a queue:
$ aws --region=us-west-2 --endpoint=http://localhost:9324 sqs create-queue --queue-name=test

{
    "QueueUrl": "http://localhost:9324/000000000000/test"
}
  1. Now execute list-queues again and notice that you have a new queue:
$ aws --region=us-west-2 --endpoint=http://localhost:9324 sqs list-queues

{
    "QueueUrls": [
        "http://localhost:9324/000000000000/test"
    ]
}

Hope this helps!

Rafid

like image 88
Rafid Avatar answered Jan 02 '23 12:01

Rafid


In our porject we run Localstack in docker. It has all AWS services available.

Very easy to use, here is an example docker compose file

like image 29
Borislav Stoilov Avatar answered Jan 02 '23 12:01

Borislav Stoilov