In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how Docker runs a Redis service". In daily operation, I believe many people have doubts about how Docker runs a Redis service. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how Docker runs a Redis service". Next, please follow the editor to study!
Installation
Just refer to the official website. I don't have any problems passing User Guide on Ubuntu-14.04.
Docker's magical AUFS file system
Execution: docker info can see information at the system level. As you can see below, the storage driver used by docker is called aufs. In short, AUFS is a stackable federated file system. Through aufs, you can flexibly assemble a target container, such as overlaying a read-and-write application container on a read-only operating system. Data changes occur during the execution of the application, only in the writable container layer, which enables flexible container assembly (such as replacing the operating system layer without affecting the application layer). At the same time, there is no need to save a large file like image, saving storage space.
Containers: 2Images: 20Storage Driver: aufs Root Dir: / var/lib/docker/aufs Dirs: 24Execution Driver: native-0.2Kernel Version: 3.13.0-24-genericWARNING: No swap limit support annoying sudo
You have to enter sudo every time you execute docker under ubuntu, which is annoying, which can be simplified by the following configuration
# add the current user to the docker user group. Note that the littcai here is the ubuntu server login user name sudo gpasswd-a littcai docker#. After the Docker background monitoring process is restarted by sudo service docker restart#, try whether it takes effect. If the docker version# does not take effect, the system restarts, then sudo reboot runs and runs a Redis service.
Execute the following command: run a docker container called common-redis,-d means to run in daemon mode, and-p means to map port 6379 in the container to port 6379 of the host host, so that the simplest redis service is created.
Sudo docker run-- name common-redis-d-p 6379 redis connects to the Redis service
Run the redis-cli command and link to the previously run common-redis service,-it means to open a tty terminal to provide interactive mode, and-- rm means to automatically delete containers that already exist with the same image running
Sudo docker run-it-- link common-redis:redis-- rm redis sh-c 'exec redis-cli-h "$REDIS_PORT_6379_TCP_ADDR"-p "$REDIS_PORT_6379_TCP_PORT"' Attach to Container
Sometimes we need to re-enter a running container, where we can use the attach command, where-I indicates interactive access. When you need to exit, use ctrl-p + ctrl-q (note that there are two consecutive instructions) instead of exit (exit will cause the container to stop).
Docker attach-I f2b0ae55d07a Save changes (new image)
First, query all the created containers with the docker ps-a command, as shown in the following figure, and learn about their CONTAINER ID=f2b0ae55d07a
Execute the following command to save the image, where-m represents the comments submitted this time,-an is author,f2b0ae55d07a for the container ID,ycai/ubuntu-jdk is the image name (user name is added as a classification by prefix here to facilitate query), and v1 is the tag name.
Docker commit-m = "Basic JDK ENV"-a = "ycai" f2b0ae55d07a ycai/ubuntu-jdk:v1
After the submission is successful, you can use the docker images command to check whether the image you just saved in the image repository, as shown in the following figure
Copy a file
Copy the files in the container to Host
Sudo docker cp container:/path hostpath
Copy the Host file into the container
Note: this operation does not modify the original image content, but creates a new image based on it.
Sudo docker insert image url path mounts the Host directory into the container
With the-v parameter, you can mount the specified directory of Host to the specified directory of the target container, so that you can modify the file directly in Host without having to copy it to the container every time.
Sudo docker run-name tomcat-v / home/user/webapps:/opt/tomcat/webapps ubuntu-tomcatDocker container connection does not understand the problem
Problem: if a directory of Host is mounted to the container through-v, but the container is started by start command after exiting, the changes of files in this directory in Host cannot be reflected in the container, the file operations in this directory in the container cannot be reflected in Host, and mount is invalid.
Phenomenon: delete the files under the mounted directory in the container, exit the container, restart to enter the container, and find that the directory has been re-mount, and supports two-way synchronization, weird
Analysis: this directory is also a remote storage mounted by Host through mount, which is out of sync due to the failure of mount on Host.
At this point, the study on "how Docker runs a Redis service" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.