Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker support #524

Merged
merged 2 commits into from
Nov 5, 2020
Merged

Add Docker support #524

merged 2 commits into from
Nov 5, 2020

Conversation

pataquets
Copy link
Contributor

Add Dockerfile to enable image building.
Using the official GCC image, latest tag. More info at https://hub.docker.com/_/gcc/

Just adding files, setting working dir and running make instructions.

Build:

$ docker build -t twemproxy .

Run:

$ docker run --rm -it -p [ext_port1:port1] -p [ext_port2:port2] -p [...] -v [your_host_config_yml]:/etc/nutcracker.yml:ro twemproxy -c /etc/nutcracker.yml --verbose=6 [other options...]

FYI, there's a still quicker to test, already built image on my Docker Hub. Test it by running:

$ docker run --rm -it -p [ext_port1:port1] -p [ext_port2:port2] -p [...] -v [your_host_config_yml]:/etc/nutcracker.yml:ro pataquets/twemproxy  -c /etc/nutcracker.yml --verbose=6 [other options...]

Using --rm instead of -d makes the container not go background and it to be deleted after stop. Should stop by CTRL+C'ing it.
In order for the Docker container to connect to external memcached or Redis instances, either them should be contactable as external IPs or hosts or be linked to other previously run Docker containers via Docker's --link option.

Here it is an example Docker Compose file I'm using (I can submit it with the PR also if you find it useful):

redis1:
  image: redis:3.2
  command: --save "" --maxmemory 128mb
  ports:
    - 63791:6379

redis2:
  image: redis:3.2
  command: --save "" --maxmemory 128mb
  ports:
    - 63792:6379

twemproxy:
  image: pataquets/twemproxy
  command: -c /etc/nutcracker.yml --verbose=6
  links:
    - redis1
    - redis2
  ports:
    - 6379:6379
    - 22222:22222
  volumes:
    - ./conf/nutcracker.redis.yml:/etc/nutcracker.yml:ro

Notice that it is tuned for two Redis instances (yml file not included, mount yours)

Optional improvement to come (maybe in another issue):

  • Create an 'official', based on your repo, automated build at Docker Hub for the image: https://docs.docker.com/docker-hub/builds/ . Just requires a free Docker Hub account and a following a quick 'Create automated build' process. I'll be happy to help on it, if needed.

@pataquets
Copy link
Contributor Author

Bump.

@AlmogBaku
Copy link

LGTM, can someone please merge this and add an autobuild for docker hub?

@pataquets
Copy link
Contributor Author

@manjuraj : ping (since you're the main commiter)

@tuananh
Copy link

tuananh commented Nov 9, 2017

Dynomite has Dockerfile. Maybe we should consider that too. https://github.com/Netflix/dynomite/blob/dev/docker/Dockerfile

Also, we should use Docker multi-stage build to further reduce footprint.

@tao12345666333
Copy link

Any update on this?

@CLAassistant
Copy link

CLAassistant commented May 13, 2019

CLA assistant check
All committers have signed the CLA.

@pataquets
Copy link
Contributor Author

@manjuraj: Anything else needed here?

I've done a quick search, and there are lots of rogue twemproxy public Docker images:

$ docker search twemproxy
NAME                          DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
zapier/twemproxy              Docker image for running twemproxy both with…   5                                       [OK]
anchorfree/twemproxy                                                          3                                       
softonic/twemproxy            Cache proxy                                     2                                       
malexer/twemproxy             A tiny (<6mb) Alpine-based Docker image of t…   1                                       [OK]
yfix/twemproxy                Dockerized twemproxy                            1                                       [OK]
giosg/twemproxy                                                               0                                       
bdossantos/twemproxy          Twemproxy, aka nutcracker is a fast and ligh…   0                                       [OK]
jgoodall/twemproxy            Docker image of twemproxy proxy server in fr…   0                                       [OK]
the40san/twemproxy            twemproxy for docker                            0                                       
ganomede/twemproxy                                                            0                                       [OK]
orimarti/twemproxy-exporter   Prometheus twemproxy exporter                   0                                       
otus/twemproxy                                                                0                                       
tarantool/twemproxy           This is a Docker image with a custom build o…   0                                       [OK]
vimagick/twemproxy            Twemproxy, aka nutcracker is a fast and ligh…   0                                       
bnusunny/twemproxy                                                            0                                       
ianblenke/twemproxy                                                           0                                       [OK]
mattrobenolt/twemproxy        Twemproxy (nutcracker)                          0                                       
phhhoto/twemproxy                                                             0                                       
ruo91/twemproxy               Twitter - Twemproxy                             0                                       [OK]
livelink/twemproxy                                                            0                                       
michaeltigr/twemproxy         Twemproxy                                       0                                       [OK]
dispatchrobot/twemproxy                                                       0                                       
gojektech/twemproxy                                                           0                                       
perlmint/twemproxy            lightweight twemproxy docker image - based o…   0                                       
studossoftware/twemproxy                                                      0                                       

Having an official one would be better, IMO.

@manjuraj manjuraj merged commit c6cc79a into twitter:master Nov 5, 2020
@manjuraj
Copy link
Collaborator

manjuraj commented Nov 5, 2020

Done. Thank you @pataquets!

@pataquets
Copy link
Contributor Author

@manjuraj You're welcome :)
How about publishing an official image built from source on Docker Hub using Automated Builds? Alternatively, GitHub has also a public Docker image registry in their CI/CD tools. I can file an issue, if needed.
Also, do you think that submitting an example Docker Compose manifest as stated in the OP would be worthwhile? I can send another PR if it's likely to be merged.

@pataquets
Copy link
Contributor Author

pataquets commented Jun 16, 2021

@manjuraj Fancy to set up an Automated Build on Docker Hub? Or any other similar 'source-built' Docker public image as a snapshot and deployable artifact.
Let me know if you have feedback about the above post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants