从RHEL 7.3 .rpm文件安装Docker镜像

时间:2017-06-14 05:26:39

标签: docker

我想使用.rpm文件在RHEL 7.3上安装Docker镜像。

我可以访问Docker .rpm文件,但是稳定包中有文件列表。

任何人都可以让我知道我应该使用哪个.rpm文件进行安装。

2 个答案:

答案 0 :(得分:0)

您可以从dockerhub portal搜索现成的RHEL docker镜像;并将其拉为// you need these includes for the function //#include <windows.h> // for windows systems #include <dirent.h> // for linux systems #include <sys/stat.h> // for linux systems #include <algorithm> // std::sort #include <opencv2/opencv.hpp> #include <iostream> //cout using namespace std; /* Returns a list of files in a directory (except the ones that begin with a dot) */ int readFilenames(std::vector<string> &filenames, const string &directory) { #ifdef WINDOWS HANDLE dir; WIN32_FIND_DATA file_data; if ((dir = FindFirstFile((directory + "/*").c_str(), &file_data)) == INVALID_HANDLE_VALUE) return; /* No files found */ do { const string file_name = file_data.cFileName; const string full_file_name = directory + "/" + file_name; const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; if (file_name[0] == '.') continue; if (is_directory) continue; filenames.push_back(full_file_name); } while (FindNextFile(dir, &file_data)); FindClose(dir); #else DIR *dir; class dirent *ent; class stat st; dir = opendir(directory.c_str()); while ((ent = readdir(dir)) != NULL) { const string file_name = ent->d_name; const string full_file_name = directory + "/" + file_name; if (file_name[0] == '.') continue; if (stat(full_file_name.c_str(), &st) == -1) continue; const bool is_directory = (st.st_mode & S_IFDIR) != 0; if (is_directory) continue; // filenames.push_back(full_file_name); // returns full path filenames.push_back(file_name); // returns just filename } closedir(dir); #endif std::sort (filenames.begin(), filenames.end()); //optional, sort the filenames return(filenames.size()); //Return how many we found } // GetFilesInDirectory void help(const char **argv) { cout << "\n\n" << "Call:\n" << argv[0] << " <directory path>\n\n" << "Given a directory of images, create a vector of\n" << "their names, read and display them. Filter out\n" << "non-images\n" << endl; } int main( int argc, const char** argv ) { if(argc != 2) { cerr << "\nIncorrect number of parameters: " << argc << ", should be 2\n" << endl; help(argv); return -1; } string folder = argv[1]; cout << "Reading in directory " << folder << endl; vector<string> filenames; int num_files = readFilenames(filenames, folder); cout << "Number of files = " << num_files << endl; cv::namedWindow( "image", 1 ); for(size_t i = 0; i < filenames.size(); ++i) { cout << folder + filenames[i] << " #" << i << endl; cv::Mat src = cv::imread(folder + filenames[i]); if(!src.data) { //Protect against no file cerr << folder + filenames[i] << ", file #" << i << ", is not an image" << endl; continue; } cv::imshow("image", src); cv::waitKey(250); //For fun, wait 250ms, or a quarter of a second, but you can put in "0" for no wait or -1 to wait for keypresses /* do whatever you want with your images here */ } }

或者,您可以按照以下方式构建自己的RHEL。

  1. docker pull <image-name>
  2. 下载二进制文件mkimage-yum.sh
  3. 修改mkimage-yum.sh以创建一个rhel 7最小tarfile,注释掉最后两行/三行(如下所示)并添加一个新行,如下所示:

    https://github.com/docker/docker/blob/master/contrib/mkimage-yum.sh
  4. 将脚本设为#tar –numeric-owner -c -C "$target" . | docker import - $name:$version #docker run -i -t $name:$version echo success tar --numeric-owner -c -C "$target" . -zf ${name}.tar.gz

  5. 将tar文件中的docker镜像构建为./mkimage-yum.sh rhel7_docker

    cat rhel7_docker.tar.gz | sudo docker import - rhel7

答案 1 :(得分:0)

要从.rpm文件安装docker,您需要下载rpm文件并使用YUM进行安装。我是为Docker Enterprise版做的。我将稳定包中的rpm文件从docker storebits下载到我的本地文件夹。我们需要selinux和docker-ee rpm文件。然后将YUM安装目录指向下载文件夹。 注意首先安装Selinux rpm,然后安装docker-ee rpm

yum install&#34; rpm文件的路径&#34;