Bootstrap FreeKB - PHP - Install memcache on Docker
PHP - Install memcache on Docker

Updated:   |  PHP articles

A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).

 

The docker pull command can be used to pull down the latest memcached image.

~]# sudo docker pull memcached
Using default tag: latest
latest: Pulling from library/memcached
5eb5b503b376: Already exists
621eeff48eb4: Pull complete
409a3a19cade: Pull complete
d6ddac56a85a: Pull complete
c64c2bb5c287: Pull complete
104707ec83cc: Pull complete
Digest: sha256:73b2c0f83f34984f2407549abe263b3f5e08444caa02f9df5baf2bf7096f53b3
Status: Downloaded newer image for memcached:latest
docker.io/library/memcached:latest

 

 

The docker images command can be used to display the image.

~]# docker images
REPOSITORY   TAG          IMAGE ID       CREATED       SIZE
memcached    latest       7a2f515f57e7   2 weeks ago   89.1MB

 

The following command can then be used to create and start the ngninx container. Let's break down this command.

  • The docker run command is used to create and start the php container.
  • The --detach flag is used to run the container in the background.
  • The --name option is used to name the container php.
  • The --publish option is used to configure both the Docker server and Samba container to listen on port 9000, which adds a rule to iptables to allow connections between the Docker system and container on port 9000.
  • The --restart unless-stopped option is used so that the container is started if the Docker server is restarted
  • The php:fpm image is us.
docker run --detach --name memcache memcached:latest

 

The docker container ls command can be used to ensure the container is running.

~]# docker container ls
CONTAINER ID   IMAGE      COMMAND                   CREATED        STATUS        PORTS        NAME
71ed97f1b614   memcached  "docker-entrypoint.s..."  5 seconds ago  Up 4 seconds  11211/tcp    memcache

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3bda4f in the box below so that we can be sure you are a human.